Plugin Directory

Changeset 514360


Ignore:
Timestamp:
03/04/2012 11:04:32 PM (14 years ago)
Author:
claytantor
Message:

Release 1.1.16

Location:
welocally-places/trunk
Files:
31 added
4 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • welocally-places/trunk/mcebutton.php

    r451428 r514360  
    2525
    2626
    27 
    28 
    2927?>
  • welocally-places/trunk/menu.php

    r466267 r514360  
    66    add_contextual_help( $main_slug, __( $main_content ) );
    77   
    8     wl_add_submenu( 'Welocally Places Subscribe', 'Subscribe', 'welocally-places-subscribe', 'wl_places_subscribe' );
     8    wl_add_submenu( 'Welocally Places Registration', 'Register', 'welocally-places-subscribe', 'wl_places_subscribe' );
    99    wl_add_submenu( 'Welocally Places About', 'About', 'welocally-places-about', 'wl_support_about' );
     10    wl_add_submenu( 'Welocally Places Manager', 'Places Manager', 'welocally-places-manager', 'wl_support_manager' );
    1011
    1112    add_filter( 'plugin_action_links', 'wl_add_settings_link', 10, 2 );
     
    2930    include_once( WP_PLUGIN_DIR . "/welocally-places/options/about.php" );
    3031}
    31    
     32
     33function wl_support_manager() {
     34    include_once( WP_PLUGIN_DIR . "/welocally-places/options/places-manager.php" );
     35}
     36
    3237
    3338function wl_add_settings_link( $links, $file ) {
     
    4954
    5055    if ( strpos( $file, 'welocally-places.php' ) !== false ) {
    51         $links = array_merge( $links, array( '<a href="admin.php?page=welocally-places-subscribe">' . __( 'Subscribe' ) . '</a>' ) );
     56        $links = array_merge( $links, array( '<a href="admin.php?page=welocally-places-subscribe">' . __( 'Register' ) . '</a>' ) );
    5257        $links = array_merge( $links, array( '<a href="admin.php?page=welocally-places-about">' . __( 'Support' ) . '</a>' ) );     
    5358    }
     
    6772    if ( $menu_slug == "welocally-places-about" ) { $help_text = file_get_contents(dirname( __FILE__ ) . '/help/about-help.php'); }
    6873   
     74    if ( $menu_slug == "welocally-places-manager" ) { $help_text = file_get_contents(dirname( __FILE__ ) . '/help/manager-help.php'); }
     75   
    6976    add_contextual_help( $profile_slug, __( $help_text ) );
    7077
  • welocally-places/trunk/options/about.php

    r466267 r514360  
    11<?php
    22global $wlPlaces;
    3 
    43?>
    54<script type="text/javascript">
    65jQuery(document).ready(function() {
     6       
    77    //set the endpoint info always 
    88    jQuery("#edit-server-link").click( function () {   
     
    4848
    4949<div class="wrap">
     50
    5051<div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
    5152<h2>Welocally Places About</h2>
     53<?php
     54$menubar_include = WP_PLUGIN_DIR . '/' .$wlPlaces->pluginDir . '/options/options-infobar.php';
     55include($menubar_include);
     56?>
    5257<?php
    5358// If options have been updated on screen, update the database
    54 
    5559if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'welocally-places-about', 'welocally_places_about_nonce' ) ) ) {
    5660
     
    5862
    5963    $options[ 'api_endpoint' ] = $_POST[ 'wl_api_endpoint' ];
     64    $options[ 'update_places' ] = $_POST[ 'wl_update_places' ];
    6065   
    6166    wl_save_options($options);
     
    6974//display error if not subscribed
    7075if(!is_subscribed()) {
    71     echo '<div class="error fade"><p><strong>' . __( 'Please Subscribe To Activate Welocally Places' ) . "</strong></p></div>\n";
     76    echo '<div class="error fade"><p><strong>' . __( 'Please Register To Activate Welocally Places' ) . "</strong></p></div>\n";
    7277}
    7378
     
    7984    <tr valign="top">
    8085        <th scope="row"><?php _e( 'Version' ); ?></th>
    81         <td><?php echo $wlPlaces->wl_places_version();  ?></td>
     86        <td><div><?php echo $wlPlaces->wl_places_version();  ?></div></td>
    8287    </tr>
     88    <tr valign="top">
     89        <th scope="row"><?php _e( 'Places Version Support' ); ?></th>   
     90        <td>           
     91        <?php if(get_places_legacy_count() > 0): ?>
     92        <div><img width="48" height="48" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/Crystal_Clear_cancel.png" alt="" title=""/></div>
     93        <div>You have recenty upgraded Welocally Places. <?php echo(get_places_legacy_count());  ?> Legacy Posts were found. You can use the <a href="<?php echo get_bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=welocally-places-manager' ?>">Place Manager</a>
     94        to track your migration, we have also created a <a href="http://welocally.com/?p=780" target="_new">Release Guide</a>. Finally, if you have problems <a href="http://www.welocally.com/?page_id=139" target="_new">email us</a>.
     95        <p/><strong>ALWAYS BACKUP PRIOR TO UPGRADE</strong></div>
     96        <?php else: ?>
     97        <img width="48" height="48" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/Crystal_Clear_check.png" alt="" title=""/>  Your places are up to date.     
     98        <?php endif; ?>
     99        </td>
     100    </tr>   
    83101    <tr valign="top">
    84102        <th scope="row"><?php _e( 'Theme Support' ); ?></th>
     
    88106        <?php else: ?>
    89107            <div><img width="48" height="48" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/Crystal_Clear_cancel.png" alt="" title=""/></div>
    90             <div><em>Just because your theme is not supported does not mean that Welocally Places will not work. Give it a try, we have a default theme that will work with most themes. We really want to support your theme so <a href="http://www.welocally.com/wordpress/?page_id=139" target="_new">contact us</a> and we will do our best to support you. <strong>Below is a list of currently supported themes.</strong></em></div> 
     108            <div><em>Just because your theme is not supported does not mean that Welocally Places will not work. Give it a try, we have default settings that will work with most themes. We really want to support your theme so <a href="http://www.welocally.com/wordpress/?page_id=139" target="_new">contact us</a> and we will do our best to support you. <strong>Below is a list of currently supported themes.</strong></em></div>
    91109            <div style="display:inline-block">
    92110            <?php
     
    117135        <th scope="row"><?php _e( 'API Server' ); ?></th>
    118136        <td>
    119             <div id="server-section">
    120                 <span id="api-endpoint-assigned" class="assigned-field"><?php echo wl_get_option('api_endpoint',null) ?></span><button id="edit-server-link" href="#">Change</button>
    121                 <div><input type="text" name="wl_api_endpoint" id="wl_api_endpoint" value="<?php echo wl_get_option('api_endpoint',null) ?>" /></div>
     137            <div id="server-section" class="action">
     138                <span id="api-endpoint-assigned" class="assigned-field" style="margin-right:10px;"><?php echo wl_get_option('api_endpoint',null) ?></span><button id="edit-server-link" href="#">Change</button>
     139                <input type="text" name="wl_api_endpoint" id="wl_api_endpoint" value="<?php echo wl_get_option('api_endpoint',null) ?>" /></div>
    122140            </div> 
    123141        </td>
  • welocally-places/trunk/options/options-general.php

    r476641 r514360  
    11<?php
    2 
     2global $wlPlaces;
    33?>
    44<div class="wrap">
    55<div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
    66<h2>Welocally Places Options</h2>
    7 
     7<?php
     8$menubar_include = WP_PLUGIN_DIR . '/' .$wlPlaces->pluginDir . '/options/options-infobar.php';
     9include($menubar_include);
     10?>
    811<?php
    912// If options have been updated on screen, update the database
     
    1114
    1215if(!is_subscribed()) {
    13     echo '<div class="error fade"><p><strong>' . __( 'Please Subscribe To Activate Welocally Places' ) . "</strong></p></div>\n";
     16    echo '<div class="error fade"><p><strong>' . __( 'Please Register To Activate Welocally Places' ) . "</strong></p></div>\n";
    1417}
    1518
     
    2629    $options[ 'infobox_thumb_height' ] = $_POST[ 'welocally_infobox_thumb_height' ];
    2730   
    28     $options[ 'map_default_marker' ] = $_POST[ 'welocally_map_default_marker' ];
    29     $options[ 'map_infobox_marker' ] = $_POST[ 'welocally_map_infobox_marker' ];
    30     $options[ 'map_infobox_close' ] = $_POST[ 'welocally_map_infobox_close' ];
    31     $options[ 'map_icon_web' ] = $_POST[ 'welocally_map_icon_web' ];
    32     $options[ 'map_icon_directions' ] = $_POST[ 'welocally_map_icon_directions' ];
     31    $options[ 'map_default_marker' ] = trim($_POST[ 'welocally_map_default_marker' ])? trim($_POST[ 'welocally_map_default_marker' ]):plugins_url() . "/welocally-places/resources/images/marker_generic_32.png";
     32    $options[ 'map_infobox_marker' ] = trim($_POST[ 'welocally_map_infobox_marker' ])? trim($_POST[ 'welocally_map_infobox_marker' ]):plugins_url() . "/welocally-places/resources/images/tipbox_180.png";
     33    $options[ 'map_infobox_close' ] = trim($_POST[ 'welocally_map_infobox_close' ])? trim($_POST[ 'welocally_map_infobox_close' ]):plugins_url() . "/welocally-places/resources/images/infobox_close_16.png";
     34    $options[ 'map_icon_web' ] = trim($_POST[ 'welocally_map_icon_web' ])?trim($_POST[ 'welocally_map_icon_web' ]):plugins_url() . "/welocally-places/resources/images/mapicons_web.png";
     35    $options[ 'map_icon_directions' ] = trim($_POST[ 'welocally_map_icon_directions' ])? trim($_POST[ 'welocally_map_icon_directions' ]):plugins_url() . "/welocally-places/resources/images/mapicons_car.png";
    3336    $options[ 'map_custom_style' ] = base64_encode(str_replace( '\"', '"', $_POST[ 'welocally_map_custom_style' ] ) );
    3437
     
    6568
    6669<?php if(is_subscribed()):?>
    67 <link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" rel="stylesheet" />
    6870<style>
    6971    #selectable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
     
    8688
    8789</style>
    88 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
    8990<script type="text/javascript" charset="utf-8">
    9091var wl_options_imgfield = '';
     
    159160});
    160161</script>
     162
     163
    161164<p><?php _e( 'These are the general settings for Welocally Places.' ); ?></p>
    162165
  • welocally-places/trunk/options/subscribe.php

    r473697 r514360  
    11<?php
    2 
    3 
     2global $wlPlaces;
     3if ( ( !empty( $_POST ) ) &&
     4    ( check_admin_referer( 'welocally-places-subscribe', 'welocally_places_subscribe_nonce' ) ) ) {
     5    if($_POST[ 'siteName' ]=='delete'){
     6        error_log('delete tokens:'.$_POST[ 'siteName' ]);
     7        delete_subscription_options();
     8    }   
     9}
    410?>
    511<script type="text/javascript">
     
    1218
    1319jQuery(document).ready(function() {
    14 
    15     wl_get_subscriber_info();
    16    
    17     jQuery("#offerCode").change( function () { 
    18         jQuery("#hosted_button_id").val(jQuery("#offerCode").val());
    19     });
    20    
    21    
     20   
     21    if(jQuery("#registration_result").html() != null){
     22        var keydata = JSON.parse(jQuery("#registration_result").html());
     23       
     24        set_form_fields(
     25            keydata.siteKey,
     26            null,
     27            keydata.subscriptionStatus);
     28       
     29    } else {
     30        wl_get_subscriber_info();
     31    }
     32
     33       
     34    jQuery("#edit-form-action").click( function () {
     35        jQuery("#siteName").toggle();
     36        jQuery("#name-assigned").toggle();
     37       
     38        jQuery("#siteHome").toggle();
     39        jQuery("#home-assigned").toggle();
     40       
     41        jQuery("#siteEmail").toggle();
     42        jQuery("#email-assigned").toggle();
     43       
     44        jQuery("#siteKey").toggle();
     45        jQuery("#key-assigned").toggle();
     46       
     47        jQuery("#siteToken").toggle();
     48        jQuery("#token-assigned").toggle();
     49       
     50        if(jQuery("#siteKey").is(":visible")){
     51            jQuery("#token-section").show();           
     52        }
     53           
     54        return false;
     55    });
     56   
     57    jQuery("#siteName").change( function () {   
     58        jQuery("#name-assigned").html(jQuery("#siteName").val());
     59    });
     60   
     61    jQuery("#siteHome").change( function () {   
     62        jQuery("#home-assigned").html(jQuery("#siteName").val());
     63    });
     64   
     65    jQuery("#siteEmail").change( function () { 
     66        jQuery("#email-assigned").html(jQuery("#siteEmail").val());
     67    });
     68   
     69    jQuery("#siteKey").change( function () {   
     70        jQuery("#key-assigned").html(jQuery("#siteKey").val());
     71    });
     72   
     73    jQuery("#siteToken").change( function () { 
     74        jQuery("#token-assigned").html(jQuery("#siteToken").val());
     75    });
     76       
    2277});
    2378
     
    4196    };
    4297   
     98    data.siteKey = '<?php echo wl_get_option('siteKey',null) ?>' ;
    4399    data.siteHome = jQuery("#siteHome").val();
    44100    data.siteName = jQuery("#siteName").val();
     
    55111            jQuery('#wl-options-error').append('<div class="error fade">ERROR 100: '+
    56112                textStatus+'</div>');
    57             Query("#publisher-status").html('ERROR 100: '+textStatus); 
     113            jQuery("#publisher-status").html('ERROR 100: '+textStatus);
    58114      },     
    59115      success: function(keydata) {
    60116       
    61117        if(keydata.key != null){
    62             set_form_fields( keydata.key, keydata.token, null, keydata.subscriptionStatus, keydata.buttonToken, keydata.paypalFormEndpoint);
     118            set_form_fields( keydata.key, keydata.token, keydata.subscriptionStatus);
    63119        } else {
    64120            jQuery('#wl-options-error').append('<div class="error">ERROR 105: Key could not be created for publisher : '+data.siteName+'</div>');
     
    75131
    76132
    77 function set_form_fields( key, token, serviceEndDateMillis, status, buttonToken, paypalEndpoint) {
    78 
    79     jQuery('#paypal-form').attr( 'action', paypalEndpoint);
    80     if(paypalEndpoint == 'https://www.paypal.com/cgi-bin/webscr'){
    81         jQuery('#paypal-subscribe-img').attr( 'src', 'https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif');
    82         jQuery('#paypal-pixel-img').attr( 'src', 'https://www.paypalobjects.com/en_US/i/scr/pixel.gif');
    83        
    84     }
     133function set_form_fields( key, token, status) {
    85134   
    86135    if(key != null) {
    87136        jQuery("#paypal-custom").val(key); 
    88137        jQuery("#key-assigned").html(key); 
    89         //set the form vals
    90         jQuery("#siteKey").val(key);
    91        
     138        jQuery("#siteKey").val(key);   
    92139    }
    93140   
    94141    if(token != null){
    95142        jQuery("#token-assigned").html(token);
    96         //welocally-places-display_token
    97143        jQuery("#welocally-places-display_token").val(token);
    98144        jQuery("#siteToken").val(token);
    99         //jQuery("#token-section").show();
    100         //jQuery("#save_options_button").show();
    101     }
    102    
    103     var subscribe_process1 = '<div><img src="<?php echo WP_PLUGIN_URL; ?>'+
    104         '/welocally-places/resources/images/subscribe_02.png" alt="" title=""/></div>';
    105 
     145    }
     146       
    106147    if(status != null) {
    107148        jQuery("#publisher-status").html(status);
    108149        if(status == 'KEY_ASSIGNED') {
     150           
     151            wl_set_cancelled_state_ajax();
     152           
     153            jQuery("#token-box").hide();
     154           
     155            jQuery("#siteToken").val('');
     156            jQuery("#token-assigned").val('');
     157           
    109158            jQuery("#key-section").show();
    110159           
    111             //the button token
    112             if(buttonToken != null) {
    113                 jQuery("#hosted_button_id").val(buttonToken);
    114             } else {
    115                 jQuery("#hosted_button_id").val('WKLRWF9WC9UZY');
    116             }
    117            
    118             jQuery("#token-section").hide();
     160           
    119161            jQuery("#save_options_button").hide();
    120162           
     
    127169            jQuery("#key-assigned-action").show();
    128170           
    129            
    130            
    131            
    132         } else if(status == 'SUBSCRIBER') {
     171            var statusimg = '<img width="75" hieght="75" style="float: left; margin-right:5px" class="align-right" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/free1.png" alt="" title=""/>'+
     172            '<span class="options-text">We have assigned a key to you, but to use or basic service you must register. Go ahead, its easy. Just press the <strong>Register Now</strong> button and we will send you your secret token.</span>';
     173            jQuery("#action-area").html(statusimg);
     174           
     175            jQuery("#primary-action-button").val('Register Now');
     176           
     177           
     178           
     179           
     180                       
     181        }  else if(status == 'REGISTERED') {
     182           
     183            jQuery("#token-box").show();
     184           
    133185            jQuery("#key-section").show();
     186            jQuery("#token-section").show();
     187           
     188            jQuery("#finished-action").hide();
     189            jQuery("#subscribed-action").hide();
     190            jQuery("#key-assigned-action").show(); 
     191           
     192           
     193            var statusimg = '<img width="75" hieght="75" style="float: left; margin-right:5px" class="align-right" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/token1.png" alt="" title=""/>'+
     194                '<span class="options-text">Great you are almost there! Now look the your inbox for the email address you gave us, and there should be an email with your free token. Enter it in into the Publisher Token field and press the <em>Save Settings</em> button.</span>';
     195            jQuery("#action-area").html(statusimg);
     196           
     197            jQuery("#primary-action-button").val('Save Token');
     198           
     199                   
     200        } else if(status == 'SUBSCRIBED') {
     201           
     202            jQuery("#token-box").show();
     203           
     204            jQuery("#key-section").show();
     205            jQuery("#token-section").show();
     206           
    134207            jQuery("#paypal-subscribe").hide();     
    135208            jQuery("#action-getkey").show();
    136209           
    137             jQuery("#token-section").show();
     210           
    138211            jQuery("#save_options_button").show();
    139            
    140            
    141            
    142212           
    143213            if(!subscribed_saved) {
     
    151221            }
    152222           
     223            var statusimg = '<img width="75" hieght="75" style="float: left; margin-right:5px" class="align-right" src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/subscribed1.png" alt="" title=""/>'+
     224                '<span class="options-text">You did it! You signed up for our product and now you can use it. You have been given access to our user portal with help, support and a whole bunch of other free welocally resouces. Be sure to <a href="<?php echo wl_server_base().'/admin/home'?>" target="_blank">log into your portal</a> as soon as possible.</span>';
     225            jQuery("#action-area").html(statusimg);
     226           
     227            jQuery("#primary-action-button").val('Save Settings');
    153228           
    154229           
    155230        } else if(status == 'CANCELLED') {
     231           
     232            jQuery("#token-box").hide();
    156233               
    157234            //ajax post to admin server
     
    159236           
    160237            jQuery("#key-section").show();
     238            jQuery("#token-section").show();
    161239           
    162240            //the button token
     
    170248            jQuery("#paypal-subscribe").show();     
    171249            jQuery("#save_options_button").hide();
    172             jQuery("#token-section").hide();
    173            
    174            
     250                       
    175251            jQuery("#finished-action").hide();
    176252            jQuery("#subscribed-action").hide();
    177253            jQuery("#key-assigned-action").show();
     254           
     255            jQuery("#primary-action-button").val('Save Settings');
    178256        } 
    179257    }
     
    214292    font-weight: bold;
    215293    text-transform: uppercase;
    216     width: 380px;
    217    
    218 }
     294    width: 95%;
     295   
     296}
     297
     298.basic-frame {
     299    display: inline-block;
     300    background:#ffffff;
     301    margin-top:10px;
     302    margin-bottom:10px;
     303    border: 2px solid #bbb;
     304    -moz-border-radius: 5px;
     305    -khtml-border-radius: 5px;
     306    -webkit-border-radius: 5px;
     307    border-radius: 5px;
     308    -moz-box-sizing: content-box;
     309    -webkit-box-sizing: content-box;
     310    -khtml-box-sizing: content-box;
     311    color: #6b6b6b;
     312    width: 95%;
     313    padding: 5px;
     314   
     315}
     316
     317
    219318
    220319.option-form-label { width: 100px; display: inline-block;}
     320
    221321.options-title2 {
    222322        border-bottom:1px solid #cccccc; padding-bottom:3px;
     
    251351}
    252352
     353#token-section {
     354    display: none;
     355}
     356
    253357#offer-section {
    254358    display: none;
     
    267371}
    268372
    269 #token-section {
    270     display: none;
    271 }
     373
    272374
    273375#wl_api_endpoint {
    274376    display: none;
    275     width: 400px;
     377    width: 95%;
    276378}
    277379
     
    280382}
    281383
    282 #siteToken {
    283     width: 400px;
     384
     385#form-signup {
     386    width: 95%;
    284387}
    285388   
     
    290393    color: #595959;
    291394    font-family: monospace;
    292     width: 400px;
     395    width: 95%;
     396    height:20px;
    293397    margin-bottom: 10px;
    294398}
    295    
    296 .option-form-field { width: 300px; }
     399
     400label { font-size:1.2em; color: #595959; font-weight:bold; width:400px; margin-top:10px;  }
     401   
     402.option-form-field {
     403    width: 95%;
     404    height:20px;
     405    margin-bottom: 10px;
     406}
    297407
    298408#plugin-options th { width: 80px; }
     
    302412
    303413<div class="wrap">
     414
    304415<div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
    305 <h2>Welocally Places Subscribe</h2>
    306 <?php
     416<h2>Welocally Places Registration</h2>
     417<?php
     418$menubar_include = WP_PLUGIN_DIR . '/' .$wlPlaces->pluginDir . '/options/options-infobar.php';
     419include($menubar_include);
     420
    307421// If options have been updated on screen, update the database
    308422
     
    311425    $options = wl_get_options();
    312426   
     427    $options[ 'siteName' ] = $_POST[ 'siteName' ];
     428    $options[ 'siteHome' ] = $_POST[ 'siteHome' ];
     429    $options[ 'siteEmail' ] = $_POST[ 'siteEmail' ];
    313430    $options[ 'siteToken' ] = $_POST[ 'siteToken' ];
    314431    $options[ 'siteKey' ] = $_POST[ 'siteKey' ];
     
    317434
    318435    echo '<div class="updated fade"><p><strong>' . __( 'Settings Saved.' ) . "</strong></p></div>\n";
     436   
     437    $json_register_request = json_encode($_POST);
     438    if($_POST[ 'siteName' ]!='delete'){
     439        error_log('register:'.$_POST[ 'siteName' ]);
     440        $result = welocally_register($json_register_request);
     441        echo '<div style="display:none" id="registration_result">'.$result.'</div>';           
     442        $resultJson = json_encode($result);
     443    }
     444   
     445
     446   
    319447}
    320448
    321449// Get options
    322450$options = wl_set_general_defaults();
    323 
    324 //display error if not subscribed
    325 if(!is_subscribed()) {
    326     echo '<div class="error fade"><p><strong>' . __( 'Please Subscribe To Activate Welocally Places' ) . "</strong></p></div>\n";
    327 }
    328 
    329 
    330451?>
    331 
    332452<div class="snp_settings wrap">
    333453
     
    341461                        <div id="content_col_1">                       
    342462                                <!-- call to action -->                             
    343                                 <div class="options-signup-text" id="signup-text"></div>
    344                                 <div id="action-container">
    345                                         <div id="key-assigned-action" style="display:none;"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/subscribe_action_1.png" alt="" title=""/></div>
    346                                         <div id="subscribed-action" style="display:none;"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/subscribe_action_2.png" alt="" title=""/></div>
    347                                         <div id="finished-action" style="display:none;"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/subscribe_action_3.png" alt="" title=""/></div>                               
    348                                 </div> 
     463                                <div class="basic-frame" id="action-area" >&nbsp;</div>
     464
    349465                                <!-- status -->
    350466                                <div class="publisher-status">
     
    354470                                <!-- the form -->
    355471                                <div id="form-signup">
     472                                 <div class="action" style="width:100%; text-align:right;"><a id="edit-form-action" href="#">Edit</a></div>
    356473                                 <form method="post" action="<?php echo get_bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=welocally-places-subscribe' ?>">
    357474                                 <fieldset>                                 
    358475                                    <div>
    359                                         <label for="siteName" class="option-form-label">Site Name:</label>
    360                                         <div id="home-assigned" class="assigned-field"><?php echo wl_get_option('siteName',get_bloginfo('name')); ?></div>
    361                                         <input type="hidden" name="siteName" id="siteName" value="<?php echo wl_get_option('siteName',get_bloginfo('name')); ?>" />
     476                                        <label for="siteName">Site Name: </label>                                       
     477                                        <div><em>You can name your site anything you want but it has to be unique to our system.</em></div>
     478                                        <div id="name-assigned" class="assigned-field"><?php echo wl_get_option('siteName',get_bloginfo('name')); ?></div>
     479                                        <input class="option-form-field" type="text"  style="display:none" name="siteName" id="siteName" value="<?php echo wl_get_option('siteName',get_bloginfo('name')); ?>" />
    362480                                    </div>
    363481                                    <div>
    364                                         <label for="siteHome" class="option-form-label">Site Home:</label>
     482                                        <label for="siteHome" >Site Home:</label>
     483                                        <div><em>This has to be the real base URL for your site, we check this when you make a request. If this site is not on the internet we can't give you a token.</em></div>
    365484                                        <div id="home-assigned" class="assigned-field"><?php echo wl_get_option('siteHome', get_bloginfo('home')); ?></div>
    366                                         <input type="hidden" name="siteHome" id="siteHome" value="<?php echo wl_get_option('siteHome',get_bloginfo('home')); ?>" />
     485                                        <input  class="option-form-field"  type="text"  style="display:none" name="siteHome" id="siteHome" value="<?php echo wl_get_option('siteHome',get_bloginfo('home')); ?>" />
    367486                                    </div>                     
    368487                                    <div>
    369                                         <label for="siteEmail" class="option-form-label" >E-mail:</label>
     488                                        <label for="siteEmail" >E-mail:</label>
     489                                        <div><em>This needs to be real, we send your token by email.</em></div>
    370490                                        <div id="email-assigned" class="assigned-field"><?php echo wl_get_option('siteEmail',get_bloginfo('admin_email')); ?></div>
    371                                         <input type="hidden" name="siteEmail" id="siteEmail"  value="<?php echo wl_get_option('siteEmail',get_bloginfo('admin_email')); ?>" />
     491                                        <input  class="option-form-field"  type="text"  style="display:none" name="siteEmail" id="siteEmail"  value="<?php echo wl_get_option('siteEmail',get_bloginfo('admin_email')); ?>" />
    372492                                    </div> 
    373493                                    <div id="key-section">
    374                                         <label for="siteKey" class="option-form-label" >Publisher Key:</label>
     494                                        <label for="siteKey" >Publisher Key:</label>
     495                                        <div><em>We assign this to you, so if you change this you should probably have a good reason like we told you to. Better to leave it alone.</em></div>
    375496                                        <div id="key-assigned" class="assigned-field"></div>
    376                                         <input type="hidden" name="siteKey" id="siteKey"  value="<?php echo wl_get_option('publisherKey',null) ?>" />
     497                                        <input  class="option-form-field"  type="text"  style="display:none" name="siteKey" id="siteKey"  value="<?php echo wl_get_option('siteKey',null) ?>" />
    377498                                    </div>
    378                                
    379                                     <div id="offer-section">
    380                                         <label for="siteToken" class="option-form-label" >Offer Code:</label>
    381                                         <input type="text" name="offerCode" id="offerCode" />
    382                                     </div>             
    383                                     <div id="token-section">
    384                                         <label for="siteToken" class="option-form-label" >Publisher Token:</label>
    385                                         <div><input type="text" name="siteToken" id="siteToken" value="<?php echo wl_get_option('publisherToken',null) ?>" /></div>
     499                                    <div id="token-box">
     500                                        <div id="token-section">
     501                                            <label for="siteToken" >Publisher Token:</label>
     502                                            <div><em>Please place the token you recieved by email here.</em></div>
     503                                            <div id="token-assigned" class="assigned-field"><?php echo wl_get_option('siteToken','') ?></div>
     504                                            <div><input  class="option-form-field" type="text" style="display:none" name="siteToken" id="siteToken" value="<?php echo wl_get_option('siteToken','') ?>" /></div>
     505                                        </div>
    386506                                    </div>
    387507                                </fieldset>
    388508                                <?php wp_nonce_field( 'welocally-places-subscribe','welocally_places_subscribe_nonce', true, true ); ?>
    389                                 <div id="save_options_button">             
    390                                 <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
    391                                 </div>
     509                               
     510                                <p class="submit"><input type="submit" id="primary-action-button" class="button-primary" value="Register Now"/></p>
     511                                                               
    392512                                </form>
    393513                            </div>
    394                             <!-- PAYPAL subscribe form WKLRWF9WC9UZY -->
    395                             <div id="paypal-subscribe" style="display:none;">   
    396                                 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal-form">
    397                                     <input type="hidden" name="cmd" value="_s-xclick">
    398                                     <input type="hidden" name="hosted_button_id" id="hosted_button_id" value="WKLRWF9WC9UZY">
    399                                     <input type="hidden" name="custom" id="paypal-custom">
    400                                     <input id="paypal-subscribe-img" type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    401                                     <img id="paypal-pixel-img" alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    402                                 </form>
    403                             </div>             
     514   
    404515                        </div>
    405516                    </td>
  • welocally-places/trunk/readme.txt

    r473697 r514360  
    1717* 2 sidebar widgets, Map Widget and Place List Widget
    1818* Fully customizable maps
    19 * Google fonts integration, no CSS required
     19* Google fonts integration, no CSS required for custom fonts
    2020* Tested with most of the common themes
    2121* Rich place information such as phone number, and website
  • welocally-places/trunk/resources/mcebutton.js

    r473697 r514360  
    11(function() {
    2    
    3    
     2
    43    tinymce.create('tinymce.plugins.welocally', {
    54        init : function(ed, url) {
     
    76                title : 'Welocally',
    87                onclick : function() {
    9                      ed.selection.setContent('[welocally/]');
     8                    if(selectedPlace != null && WELOCALLY.meta.post != null ){
     9                        ed.selection.setContent(WELOCALLY.places.tag.makePlaceTag(selectedPlace, WELOCALLY.meta.post));
     10                    }
    1011                }
    1112            });
  • welocally-places/trunk/resources/places.css

    r466267 r514360  
    55.text-align-right { text-align:right; }
    66
     7
     8.align-right { float:right; margin: 0 0 10px 10px; }
     9.align-left { float:left; margin: 0 0 10px 10px; }
     10
     11
     12/*-- jquery --*/
     13.ui-button-text {
     14    color: #505050;
     15}
    716
    817/*--- we locally specific --*/
     
    323332
    324333
    325 #map_canvas_post {display:none; height:250px}
    326 
    327 #wl-place-content { list-style-type: none; margin: 0; padding: 0; width: 100%; }
    328 #wl-place-content ul {margin: 0; padding: 0;}
    329 #wl-place-content li {
     334.map_canvas_post {display:none; height:250px}
     335
     336.wl-place-content { list-style-type: none; margin: 0; padding: 3px; width: 100%; }
     337.wl-place-content ul {margin: 0; padding: 0;}
     338.wl-place-content li {
    330339            font-size: 1.0em;           
    331340            display:inline-block;
     
    339348}
    340349
    341 #wl-place-content table
     350.wl-place-content table
    342351{
    343352    border-collapse: collapse;
     
    345354}
    346355
    347 #wl-place-content td.wl-place-link-item
     356.wl-place-content td.wl-place-link-item
    348357{
    349358    vertical-align:middle;
     
    364373.wl_options_heading { margin-top:10px; color: #333333; font-variant: small-caps; font:1.2em Verdana, Arial, Helvetica, sans-serif; text-transform:uppercase}
    365374
    366 .form-table {  width:98%; margin-bottom:10px;  border: 1px solid #888888; background: #eeeeee; padding: 5px; }
     375.form-table { 
     376    border-collapse: separate;
     377    width:98%; margin-bottom:10px;  border: 1px solid #888888; background: #f2f2f2; padding: 5px; }
    367378
    368379#welocally_cat_map_none{ display:inline-block; width: 53px; height:44px; border: 0px solid #888888; background:url('images/layout_selector_none_up.png') no-repeat 0 bottom;}
     
    382393
    383394.welocally-error {
    384     font-size:1.2em;
    385     color: #A30F0F;
    386     font-variant: small-caps; font:1.2em Verdana, Arial, Helvetica, sans-serif;
     395    border: #D12424 1px solid;
     396    color: #D12424;
     397    font: 1.2em Verdana, Arial, Helvetica, sans-serif;
     398    background-color: #EBC7C7;
     399    -moz-border-radius:3px;
     400    -webkit-border-radius:3px;
     401    margin-bottom: 5px;
    387402}
    388403
    389404.welocally-update {
    390     font-size:1.2em;
    391     color: #A38D0F;
    392     font-variant: small-caps; font:1.2em Verdana, Arial, Helvetica, sans-serif;
    393 }
     405    border: #96841A 1px solid;
     406    color: #96841A;
     407    font: 1.2em Verdana, Arial, Helvetica, sans-serif;
     408    background-color: #F5EAAB;
     409    -moz-border-radius:3px;
     410    -webkit-border-radius:3px;
     411    margin-bottom: 5px;
     412}
     413
     414.welocally-message {
     415    border: #2484BF 1px solid;
     416    color: #2484BF;
     417    font: 1.2em Verdana, Arial, Helvetica, sans-serif;
     418    background-color: #D3E3ED;
     419    -moz-border-radius:3px;
     420    -webkit-border-radius:3px;
     421    margin-bottom: 5px;
     422}
     423
    394424
    395425.welocally-context-help {
     
    446476}
    447477
    448 
    449 
     478#helpbar {
     479    width:97%;
     480    margin-bottom:10px;
     481    margin-top:10px;   
     482    border: 1px solid #888888;
     483    background: #eeeeee; padding: 5px;
     484    border-radius:3px;
     485    padding: 4px;
     486    width:auto;
     487    -moz-border-radius:3px;
     488    -webkit-border-radius:3px;
     489}
     490
     491.options-text {
     492    color: #888888;
     493    font-style: italic;
     494    font-size:1.4em;
     495    font: Arial, Helvetica, sans-serif;
     496}
     497
     498.button-bar {
     499    font-size: 65%;
     500}
     501
     502
     503/* place tag*/
     504
     505.share-place-tag {
     506    margin:0px;
     507    width:100%;
     508    display:none;
     509}
     510
     511.share-place-tag-tagtext {
     512    width: 98%;
     513    font-family: monospace;
     514    margin:2px;
     515}
     516
     517.post-place-tag-tagtext {
     518    font-family: monospace;
     519    margin:2px;
     520}
     521
     522.share-place-tag-info {
     523    display: inline-block;
     524    font-size:0.7em;
     525    color: #888888;
     526    font-style: italic;
     527    font: Arial, Helvetica, sans-serif;
     528    width:72%;
     529    margin-left: 3px;
     530}
     531
     532.tag-powered-by {
     533    display:inline-block;
     534    text-align:right;
     535    font-size:0.7em; 
     536    width:26%;
     537}
     538
     539/*style of the links below a place*/
     540ul.wl-place-links{
     541    list-style-type:none;
     542    margin: 0px;
     543    padding: 0px;
     544    -webkit-padding-start: 0px;
     545    padding-left: 0px;
     546}
     547ul.wl-place-links li{ display:inline-block; margin: 0px 0px 0px 0px; padding: 0px; padding-left: 0px; }
     548
     549.share-place-tag { background-color: #f9f9f9; border: 1px solid #e1e1e1; padding: 3px;}
     550
     551/*ul.wl-place-links li a{ border-left:8px solid white; text-decoration:none; padding:0;  }*/
     552
     553
     554
     555
     556
     557.wl-place-widget-links { text-align:right; }
     558
     559div.gmap img {max-width:100000px; max-width: none}
     560
  • welocally-places/trunk/resources/places.js

    r473697 r514360  
    1313 * limitations under the License.
    1414 */
     15
     16function preload(arrayOfImages) {
     17    jQuery(arrayOfImages).each(function(){
     18        jQuery('<img/>')[0].src = this;
     19        // Alternatively you could use:
     20        // (new Image()).src = this;
     21    });
     22}
     23
     24
    1525function replaceAll(txt, replace, with_this) {
    1626  return txt.replace(new RegExp(replace, 'g'),with_this);
     
    1929function buildContentForInfoForList(place, index, permalink, webicon, directionsicon) {
    2030        var content= '<div class="wl-place-name wl-place-widget-name" id="plugin-place-name'+index+'"><a href="'+
    21                 permalink+'" >'+place.name+'</a></div>'+
    22                 '<div class="wl-place-address wl-place-widget-address">'+place.address+", "+
    23                 place.city+" "+
    24                 place.state+" "+
    25                 place.postalCode+'</div>';
     31                permalink+'" >'+place.properties.name+'</a></div>'+
     32                '<div class="wl-place-address wl-place-widget-address">'+place.properties.address+", "+
     33                place.properties.city+" "+
     34                place.properties.province+" "+
     35                place.properties.postcode+'</div>';
    2636       
    2737        //only add phone if exists
    28         if(place.phone != null) {   
    29                 content = content+'<div class="wl-place-widget-phone">'+place.phone+'</div>';
     38        if(place.properties.phone != null) {   
     39                content = content+'<div class="wl-place-widget-phone">'+place.properties.phone+'</div>';
    3040        }
    3141       
    3242        //only add website if it exists
    3343        content = content+'<div class="wl-place-widget-links" id="plugin-place-links'+index+'">';
    34         if(place.website != null && place.website != '') {
    35                 var website = place.website;
    36                 if(place.website.indexOf('http://') == -1) {
    37                     website = 'http://'+place.website;
     44        if(place.properties.website != null && place.properties.website != '') {
     45                var website = place.properties.website;
     46                if(place.properties.website.indexOf('http://') == -1) {
     47                    website = 'http://'+place.properties.website;
    3848                }                   
    3949                content = content+'<a href="'+
    4050                    website+'" target="_new"><img src="'+webicon+'" border="0" class="wl-link-image"/></a>';
    4151                   
    42         } else if(place.url != null && place.url != '') {
    43             var website = place.url;
    44             if(place.url.indexOf('http://') == -1) {
    45                 website = 'http://'+place.url;
    46             }                   
    47             content = content+'<a href="'+
    48                 website+'" target="_new"><img src="'+webicon+'" border="0" class="wl-link-image"/></a>';
    49         }
    50        
    51        
    52         if(place.city != null && place.state != null){
    53             var qS = place.city+" "+place.state;
    54             if(place.address != null)
    55                 qs=place.address+" "+qS;
    56             if(place.postalCode != null)
    57                 qs=qs+" "+place.postalCode;
     52        }
     53       
     54       
     55        if(place.properties.city != null && place.properties.province != null){
     56            var qS = place.properties.city+" "+place.properties.province;
     57            if(place.properties.address != null)
     58                qs=place.properties.address+" "+qS;
     59            if(place.properties.postalcode != null)
     60                qs=qs+" "+place.properties.postalcode;
    5861            var qVal = qs.replace(" ","+");
    5962            content = content+'<a href="http://maps.google.com/maps?f=d&source=s_q&hl=en&geocode=&q='+qVal+
     
    7881    directionsicon,
    7982    linkedTitle,
    80     linkUrl,
    8183    showThumb,
    8284    thumbUrl) {
    8385   
    84     var myLatLng = new google.maps.LatLng(place.latitude, place.longitude);
     86    var myLatLng = new google.maps.LatLng(place.geometry.coordinates[1], place.geometry.coordinates[0]);
    8587    var mMarker = new google.maps.Marker({
    8688        container: container,
     
    9799        directionsicon: directionsicon,
    98100        linkedTitle: linkedTitle,
    99         linkUrl: linkUrl,
    100101        showThumb: showThumb,
    101102        thumbUrl: thumbUrl
     
    103104   
    104105    google.maps.event.addListener(mMarker, 'click', function(event) {
    105        
    106106            var placeSelected = mMarker.place;
    107107            var container = mMarker.container;
     
    109109            var newLocation =
    110110                new google.maps.LatLng(
    111                 placeSelected.latitude, placeSelected.longitude);
     111                placeSelected.geometry.coordinates[1], placeSelected.geometry.coordinates[0]);
    112112           
    113113            map.panTo(mMarker.position);
    114114                       
    115             boxText.innerHTML = buildContentForInfoWindow(
    116                 mMarker.place, ', ', mMarker.webicon, mMarker.directionsicon,
    117                 mMarker.linkedTitle, mMarker.linkUrl,
    118                 mMarker.showThumb, mMarker.thumbUrl);
    119                    
     115            //lets do this the jquery way
     116            var contentsBox = jQuery(document.createElement('div'));
     117           
     118            var contents = buildContentForInfoWindow(
     119                    WELOCALLY.places.map.infobox.baseWidth,
     120                    mMarker.place, ', ', mMarker.webicon, mMarker.directionsicon,
     121                    mMarker.linkedTitle, mMarker.link,
     122                    mMarker.showThumb, mMarker.thumbUrl,
     123                    WELOCALLY.places.map.infobox.thumbMaxSize);
     124           
     125           
     126            jQuery(contentsBox).html(contents);
     127                       
     128            boxText.innerHTML = contents;
     129             
     130            jQuery(boxText).find('li a img').load(function(){
     131                console.log('image loaded');
     132                jQuery(boxText).find('li a').css('background','none').css('padding','0px');
     133                jQuery(boxText).css('line-height','15px');
     134                jQuery(boxText).find('ul').css('margin','0px');
     135            });
     136                       
    120137            //if this is the widget show the excerpt
    121138            if(container == 'places-map'){
    122                 ib_widget.open(mMarker.map, this);
     139               
     140                WELOCALLY.places.map.infobox.setOffset(contentsBox,ib_widget);
     141                ib_widget.open(mMarker.map, this); 
     142                ib_widget.show();
     143                ib.hide();
    123144                jQuery('#details-place-name').html('<a href="'+
    124                         mMarker.link+'" >'+placeSelected.name+'</a>');
     145                        mMarker.link+'" >'+placeSelected.properties.name+'</a>');
    125146                jQuery('#details-place-excerpt').html(mMarker.excerpt);
    126147                jQuery('#place-details').show();
    127148                jQuery('#sp-click-action-call').hide();
    128             } else {
     149               
     150            } else if(container == 'category-map') {
     151                               
     152                WELOCALLY.places.map.infobox.setOffset(contentsBox,ib);
    129153                ib.open(mMarker.map, this);
     154                ib.show();
     155                ib_widget.hide();
    130156            }
    131            
     157            jQuery('#info-contents-box ul li a').css('background','none').css('padding','0px');
    132158           
    133159           
     
    161187   
    162188        var content= '<div class="wl-infobox-text_scale wl-place-name title-selectable-place wl-infobox-text_scale">'+'<a href="'+
    163                 link+'" >'+place.name+'</a>'+'</div>';
     189                link+'" >'+place.properties.name+'</a>'+'</div>';
    164190       
    165191        if(showExcerpt){
     
    170196}
    171197
    172 function buildContentForInfoWindow(place, catsDiv, wicon, dicon,
    173         linkedTitle, linkUrl,
    174         showThumb, thumbUrl) {
     198function buildContentForInfoWindow(
     199        baseWidth,
     200        place,
     201        catsDiv,
     202        wicon,
     203        dicon,
     204        linkedTitle,
     205        linkUrl,
     206        showThumb,
     207        thumbUrl,
     208        thumbMax) {
    175209                       
    176     var placeNameTemplate1= '<div class="wl-place-name wl-place-widget-name"><a href="{PLACE_POST_LINK}">{PLACE_NAME}</a></div>';
    177    
    178     var placeNameTemplate2= '<div class="wl-place-name wl-place-widget-name">{PLACE_NAME}</div>';
    179    
    180     var webTemplate='<li style="display:inline-block; margin-right:0px"><a href="{WEB_LINK}" target="_blank"><img src="{WEB_ICON}" border="0" class="wl-link-image" border="0"></a><div style="position:relative; display: inline-block; font-size:85%; top: -10px"><a href="{WEB_LINK}" target="_blank">web</a></div></li> ';
    181 
    182     var directionsTemplate='<li style="display:inline-block; margin-right:0px"><a href="{DRIVE_LINK}" target="_blank"><img src="{DRIVE_ICON}" class="wl-link-image"></a><div style="position:relative; display: inline-block; font-size:85%; top: -10px"><a href="{DRIVE_LINK}" target="_blank">directions</a></div></li>';
    183    
    184     var thumbTemplate1='<a href="{PLACE_POST_LINK}"><img src="{THUMB_IMAGE_URL}" border="0" style="float:left; margin-right:5px; max-width:150px; max-height:150px"></a>';
    185 
    186     var thumbTemplate2='<img src="{THUMB_IMAGE_URL}" border="0" style="float:left; margin-right:5px; max-width:150px; max-height:150px">';
    187    
    188     var content='<div id="infobox_content">{THUMB_CONTENT}<div style="margin-left:5px">{PLACE_NAME_CONTENT}<div class="wl-place-address wl-place-widget-address">{PLACE_ADDRESS}</div><div class="wl-place-widget-phone">{PLACE_PHONE}</div><div class="wl-place-widget-links"> <ul style="text-align:left; list-style-type: none; padding: 0px; margin: 0px;">{WEB_CONTENT}{DIRECTIONS_CONTENT}</ul></div></div></div><div style="clear:left; height:1px">&nbsp;</div>';
    189            
    190         //thumb
    191         if(showThumb){
    192            
    193             if(linkedTitle){
    194                 var thumbContent = thumbTemplate1
    195                     .replace('{PLACE_POST_LINK}', linkUrl)
    196                     .replace('{THUMB_IMAGE_URL}',thumbUrl)
    197                     .replace('{THUMB_IMAGE_URL}',thumbUrl);
    198                 content = content.replace('{THUMB_CONTENT}',thumbContent);
    199                
    200             } else {
    201                 var thumbContent = thumbTemplate2
     210    //lets do this the jquery way
     211    //var baseWidth = 100;
     212   
     213    var contentsBox = jQuery(document.createElement('div'))
     214        .attr('id','info-contents-box');
     215   
     216    if(showThumb){ 
     217        var size = eval(thumbMax.replace('px',''))+baseWidth;
     218        jQuery(contentsBox)
     219        .css('width',size+'px')
     220        .css('height',size+'px')
     221        .append('<img class="infobox-img" src="{THUMB_IMAGE_URL}" border="0" style="float:left; margin-right:5px; max-width:{THUMB_MAX}; max-height:{THUMB_MAX}">'
    202222                .replace('{THUMB_IMAGE_URL}',thumbUrl)
    203                 .replace('{THUMB_IMAGE_URL}',thumbUrl);
    204                 content = content.replace('{THUMB_CONTENT}',thumbContent);
    205             }
    206            
    207            
    208            
    209         } else {
    210             content = content.replace('{THUMB_CONTENT}','');
    211         }
    212        
    213         content = content.replace('{THUMB_CONTENT}','');
    214        
    215         //placename
    216         if(linkedTitle){
    217             var placeNameContent = placeNameTemplate1
    218                 .replace('{PLACE_POST_LINK}', linkUrl)
    219                 .replace('{PLACE_NAME}', place.name);
    220            
    221             content = content.replace('{PLACE_NAME_CONTENT}',placeNameContent);
    222            
    223         } else {
    224             var placeNameContent = placeNameTemplate2
    225             .replace('{PLACE_NAME}', place.name);
    226        
    227             content = content.replace('{PLACE_NAME_CONTENT}',placeNameContent);
    228         }
    229        
    230        
    231                
    232         //address
    233         if(place.city != null && place.state != null){
    234             var fullAddress = place.city+" "+place.state;
    235             if(place.address != null)
    236                 fullAddress=place.address+", "+fullAddress;
    237             if(place.postalCode != null)
    238                 fullAddress=fullAddress+" "+place.postalCode;           
    239             var content= content       
    240             .replace('{PLACE_ADDRESS}', fullAddress);
    241            
    242             var searchQuery = replaceAll(fullAddress, ',', '');
    243             searchQuery = replaceAll(searchQuery, ' ', '+');
    244            
    245             var drivingUrl = 'http://maps.google.com/maps?f=d&source=s_q&hl=en&geocode=&q='+searchQuery;
    246                    
    247             var directionsContent =
    248                 replaceAll(directionsTemplate, '{DRIVE_LINK}', drivingUrl);         
    249    
    250             directionsContent = directionsContent       
    251                 .replace('{DRIVE_ICON}', dicon);   
    252             content= content       
    253                 .replace('{DIRECTIONS_CONTENT}', directionsContent);       
    254            
    255            
    256         } else {
    257             content= content       
    258                 .replace('{PLACE_ADDRESS}', '');
    259             content= content       
    260                 .replace('{DIRECTIONS_CONTENT}', '');
    261         }
    262        
    263         //phone
    264         if(place.phone != null) {   
    265             content= content       
    266             .replace('{PLACE_PHONE}', place.phone);
    267         } else {
    268             content= content       
    269             .replace('{PLACE_PHONE}', '');
    270         }
    271        
    272         //website
    273         if(place.website != null && place.website != '') {
    274            
    275             var webContent =
    276                 replaceAll(webTemplate, '{WEB_LINK}', place.website );
    277             webContent =
    278                 replaceAll(webContent, '{WEB_ICON}', wicon );
    279             content= content       
    280                 .replace('{WEB_CONTENT}', webContent);
    281            
    282            
    283         } else {
    284             content= content       
    285             .replace('{WEB_CONTENT}', '');
    286         }
    287    
    288         return content;
     223                .replace('{THUMB_MAX}',thumbMax)
     224                .replace('{THUMB_MAX}',thumbMax)
     225                );
     226        jQuery(contentsBox).css('height',jQuery('.infobox-img',contentsBox).css('max-height'));
     227    } else {
     228        jQuery(contentsBox)
     229        .css('width',baseWidth+'px');
     230    }
     231   
     232    //place name
     233    jQuery(contentsBox).append(
     234            '<div class="wl-place-name wl-widget-place-name"><a href="{PLACE_POST_LINK}">{PLACE_NAME}</a></div>'
     235            .replace('{PLACE_POST_LINK}',linkUrl)
     236            .replace('{PLACE_NAME}',place.properties.name)         
     237    );
     238   
     239    //address
     240    var fullAddress = '';
     241       
     242    if(place.properties.city != null && place.properties.province != null){
     243        var fullAddress = place.properties.city+" "+place.properties.province;
     244        if(place.properties.address != null)
     245            fullAddress=place.properties.address+", "+fullAddress;
     246        if(place.properties.postcode != null)
     247            fullAddress=fullAddress+" "+place.properties.postcode; 
     248    }
     249       
     250    jQuery(contentsBox).append(
     251            '<div class="wl-place-address wl-place-widget-address">{PLACE_ADDRESS}</div>'
     252            .replace('{PLACE_ADDRESS}',fullAddress));
     253   
     254    //phone
     255    if(place.properties.phone != null) {   
     256        jQuery(contentsBox).append(
     257                '<div>{PLACE_PHONE}</div>'
     258                .replace('{PLACE_PHONE}',place.properties.phone));
     259    }
     260       
     261    //links
     262    var infoBoxLinks = jQuery(document.createElement('ul')).attr('id','info-box-links');
     263    jQuery(infoBoxLinks)
     264        .css('display','inline-block')
     265        .css('list-style-type:','none');       
     266    var linkTemplate = '<li style="display:inline-block;"><a href="{PLACE_LINK_URL}"><img src="{PLACE_LINK_TYPE_IMG}"/></a></li>';
     267   
     268    if(place.properties.website != null) {
     269        jQuery(infoBoxLinks).append(
     270                new String(linkTemplate)
     271                .replace('{PLACE_LINK_URL}',place.properties.website)
     272                .replace('{PLACE_LINK_TYPE_IMG}',wicon)         
     273        );
     274       
     275    }
     276   
     277    if(place.properties.city != null &&
     278            place.properties.province != null &&
     279            place.properties.postcode != null){
     280       
     281        var searchQuery = replaceAll(fullAddress, ',', '');
     282        searchQuery = replaceAll(searchQuery, ' ', '+');
     283        var drivingUrl = 'http://maps.google.com/maps?f=d&source=s_q&hl=en&geocode=&q='+searchQuery;
     284       
     285        jQuery(infoBoxLinks).append(
     286                new String(linkTemplate)
     287                .replace('{PLACE_LINK_URL}',drivingUrl)
     288                .replace('{PLACE_LINK_TYPE_IMG}',dicon)
     289        );     
     290    }
     291   
     292    jQuery(contentsBox).append(infoBoxLinks);
     293
     294    return jQuery('<div>').append(jQuery(contentsBox).clone()).html();
     295
    289296}
    290297
     
    468475        this.style.cursor = "default";
    469476      });
     477     
    470478    }
    471479
     
    10261034
    10271035
    1028 //every document
    1029 jQuery(document).ready(function(jQuery) {
    1030    
    1031    
    1032 });
     1036
     1037
  • welocally-places/trunk/resources/themes.json

    r473697 r514360  
    2323        "themeName": "Sight",
    2424        "themeDirectory": "sight"
    25     } 
     25    }, 
     26    {
     27        "themeName": "Delicate",
     28        "themeDirectory": "delicate"
     29    },
     30    {
     31        "themeName": "zBench",
     32        "themeDirectory": "zbench"
     33    },
     34    {
     35        "themeName": "iFeature",
     36        "themeDirectory": "ifeature"
     37    }
     38   
    2639]
  • welocally-places/trunk/template-tags.php

    r473697 r514360  
    5050        $default_font_color = '000000';
    5151        $default_font_size = '1.2';
    52         $default_cat_map_layout = 'center';
     52        $default_cat_map_layout = 'none';
    5353        $default_cat_map_select_width = '160';
    5454        $default_cat_map_select_height = '160';
    5555        $default_api_endpoint = 'https://api.welocally.com';
    5656        $default_slider_amount = '100' ;
     57        $default_update_places = 'off';
    5758       
    5859        $default_infobox_title_link = 'off';
     
    6465        $default_cat_map_select_title= 'on';
    6566        $default_cat_map_select_excerpt= 'on';
     67       
     68        $default_site_name= get_bloginfo('name');
     69        $default_site_home= get_bloginfo('home');
     70        $default_email=  get_bloginfo('admin_email');
    6671       
    6772
     
    9095        if ( !array_key_exists( 'map_icon_web', $options ) ) { $options[ 'map_icon_web' ] = $default_icon_web; $changed = true; }
    9196        if ( !array_key_exists( 'map_custom_style', $options ) ) { $options[ 'map_custom_style' ] = $default_map_style; $changed = true; }
     97       
     98        //site
    9299        if ( !array_key_exists( 'siteKey', $options ) ) { $options[ 'siteKey' ] = $default_map_style; $changed = true; }
    93100        if ( !array_key_exists( 'siteToken', $options ) ) { $options[ 'siteToken' ] = $default_map_style; $changed = true; }
     101        if ( !array_key_exists( 'siteName', $options ) ) { $options[ 'siteName' ] = $default_site_name; $changed = true; }
     102        if ( !array_key_exists( 'siteHome', $options ) ) { $options[ 'siteHome' ] = $default_site_home; $changed = true; }
     103        if ( !array_key_exists( 'siteEmail', $options ) ) { $options[ 'siteEmail' ] = $default_email; $changed = true; }
     104       
     105       
    94106        if ( !array_key_exists( 'font_place_name', $options ) ) { $options[ 'font_place_name' ] = $default_font; $changed = true; }
    95107        if ( !array_key_exists( 'color_place_name', $options ) ) { $options[ 'color_place_name' ] = $default_font_color; $changed = true; }
     
    107119        if ( !array_key_exists( 'cat_map_select_width', $options ) ) { $options[ 'cat_map_select_width' ] = $default_cat_map_select_width; $changed = true; }
    108120        if ( !array_key_exists( 'cat_map_select_height', $options ) ) { $options[ 'cat_map_select_height' ] = $default_cat_map_select_height; $changed = true; }
    109         if ( !array_key_exists( 'api_endpoint', $options ) ) { $options[ 'api_endpoint' ] = $default_api_endpoint; $changed = true; }
    110121        //welocally_cat_map_infobox_text_scale
    111122        if ( !array_key_exists( 'cat_map_infobox_text_scale', $options ) ) { $options[ 'cat_map_infobox_text_scale' ] = $default_slider_amount; $changed = true; }
     123       
     124        //about options
     125        if ( !array_key_exists( 'api_endpoint', $options ) ) { $options[ 'api_endpoint' ] = $default_api_endpoint; $changed = true; }
     126        if ( !array_key_exists( 'update_places', $options ) ) { $options[ 'update_places' ] = $default_update_places; $changed = true; }
     127       
     128        if ( !array_key_exists( 'update_places', $options ) ) { $options[ 'update_places' ] = $default_update_places; $changed = true; }
     129        if ( !array_key_exists( 'update_places', $options ) ) { $options[ 'update_places' ] = $default_update_places; $changed = true; }
     130        if ( !array_key_exists( 'update_places', $options ) ) { $options[ 'update_places' ] = $default_update_places; $changed = true; }
    112131       
    113132   
     
    123142   
    124143    function wl_save_options($options) {
     144       
     145        $options_r = print_r($options, true);
     146        //error_log("saving options:".$options_r, 0);
    125147        global $wlPlaces;
    126148        $wlPlaces->saveOptions($options);
     149       
     150        //update places
     151        if ( array_key_exists( 'update_places', $options )) {
     152            update_places();
     153        }
     154    }
     155   
     156    function delete_post_places($post_id=0) {
     157        global $wlPlaces;       
     158        if (!$post_id) $post_id = get_the_ID();     
     159        $wlPlaces->deletePostPlaces($post_id);
     160    }
     161   
     162    function delete_post_places_meta($post_id=0) {
     163        global $wlPlaces;       
     164        if (!$post_id) $post_id = get_the_ID();     
     165        $wlPlaces->deletePostPlacesMeta($post_id);
    127166    }
    128167   
     
    144183        return isset($is_token_valid);
    145184    }   
     185   
     186   
     187    function is_registered(){
     188        $is_token_valid = wl_get_option('siteToken', null);
     189        return isset($is_token_valid);
     190    }   
    146191
    147192       
     
    161206        return false;
    162207    }
     208   
     209   
     210    function update_places(){
     211        global $wlPlaces;
     212        $cat_ID = $wlPlaces->placeCategory();       
     213        $places_in_category_posts = get_places_posts_for_category($cat_ID);
     214       
     215        $index = 0;
     216        foreach( $places_in_category_posts as $post ) {
     217           
     218           
     219            $placeJsonRaw = str_replace(
     220                        "\'", "",
     221                        get_post_meta( $post->ID, '_PlaceSelected', true ));       
     222                                           
     223            $placeJson =
     224                json_decode($placeJsonRaw, true);
     225           
     226            $pname = str_replace("\\'", "'", $placeJson{'name'});
     227           
     228            if($pname != null){
     229                $newPlaceJson = convert_legacy_place($placeJsonRaw);
     230                update_post_meta( $post->ID, '_PlaceSelected',  $newPlaceJson);
     231            }
     232                   
     233        }       
     234       
     235    }
     236   
     237    /**
     238     * 
     239     * takes a legacy json string in and returns a json string out
     240     */
     241    function convert_legacy_place($legacyPlaceJsonRaw){
     242        $legacyPlaceJson =
     243                json_decode($legacyPlaceJsonRaw, true);
     244       
     245        $legacyCategories = $legacyPlaceJson{'categories'};
     246       
     247        $template = file_get_contents(dirname( __FILE__ ) . '/templates/newplace-template.json');
     248       
     249        $resultJson = sprintf (
     250                $template,
     251                str_replace("SG_", "WL_",$legacyPlaceJson{'externalId'}), //1
     252                $legacyPlaceJson{'name'}, //2
     253                $legacyPlaceJson{'address'}, //3
     254                $legacyPlaceJson{'city'}, //4
     255                $legacyPlaceJson{'state'}, //5
     256                $legacyPlaceJson{'postalCode'},//6
     257                $legacyPlaceJson{'phone'},//7
     258                $legacyPlaceJson{'website'}, //8
     259                $legacyCategories[0], //9
     260                "", //10
     261                "",//11
     262                $legacyPlaceJson{'latitude'}, //12
     263                $legacyPlaceJson{'longitude'} //13     
     264                );             
     265               
     266        return trim($resultJson );
     267    }
     268   
     269    //select post_id from wp_postmeta where meta_key='_PlaceSelected';
     270    function get_legacy_posts() {
     271        global $wpdb;
     272       
     273        $query = "SELECT $wpdb->posts.*, $wpdb->postmeta.meta_value
     274                FROM $wpdb->posts,$wpdb->postmeta 
     275            WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
     276            AND $wpdb->postmeta.meta_key='_PlaceSelected'";
     277           
     278       
     279        $metaPlaces = $wpdb->get_results($query, OBJECT);
     280        $arr = array();
     281        foreach ($metaPlaces as $post)
     282        {
     283            $placeJson =
     284                json_decode($post->meta_value, true);
     285            if(!empty ($placeJson['externalId']) ||
     286                !empty ($placeJson['simpleGeoId']) ){
     287                array_push($arr, $post);   
     288            }
     289        }
     290        return $arr;       
     291       
     292    }
     293   
     294    /**
     295     * this function is used to determine the number of legacy places that will need to be
     296     * converted.
     297     *
     298     */
     299    function get_places_legacy_count() {
     300        global $wpdb;
     301           
     302        $query = "SELECT $wpdb->postmeta.*
     303                FROM $wpdb->postmeta
     304            WHERE $wpdb->postmeta.meta_key = '_PlaceSelected'";
     305           
     306        $metaPlaces = $wpdb->get_results($query, OBJECT);
     307        $legacyCount = 0;
     308        foreach ($metaPlaces as $place)
     309        {
     310            $placeJson =
     311                json_decode($place->meta_value, true);
     312           
     313            if(!empty ($placeJson['externalId']) ||
     314                !empty ($placeJson['simpleGeoId']) )           
     315            {
     316                $legacyCount = $legacyCount+1;
     317            }
     318        }
     319        return $legacyCount;
     320       
     321    }
     322   
     323   
    163324   
    164325    /**
     
    219380       
    220381        $categoryPlacesId = $wlPlaces->placeCategory();
    221        
     382
    222383        $categories_query = "select
    223384                        $wpdb->posts.*
     
    238399                                AND $wpdb->posts.post_status = 'publish'
    239400                                GROUP BY $wpdb->posts.ID)";
    240                                    
     401                               
    241402        $return = $wpdb->get_results($categories_query, OBJECT);
     403       
    242404        return $return;
    243405    }
    244406   
     407   
     408    /**
     409     * is this obsolete?
     410     */
    245411    function get_place_post_ids_by_category( $orderBy = null, $orderDir = null, $categoryId = null ) {
    246412
     
    266432        //iterate through those, we could probably come up with a query here
    267433        //because we are effectively creating a join, but this is already a pretty
    268         //complex query, this should probably be improved later
    269            
    270            
    271            
     434        //complex query, this should probably be improved later         
    272435        $return = $wpdb->get_results($placesQuery, OBJECT);
    273436        return $return;
    274437    }
    275438   
    276     function get_place_by_post_id( $postId = null) {
     439    function get_legacy_place_by_post_id( $postId = null) {
    277440        global $wpdb;
    278441           
     
    289452       
    290453        delete_post_meta($postId, '_PlaceSelected');
    291         delete_post_meta($postId, '_PlaceSelected');
    292        
     454       
     455    }
     456
     457    function delete_subscription_options() {
     458   
     459        $options = wl_get_options();
     460       
     461        $options['siteKey'] = null;
     462        $options['siteToken'] = null;
     463   
     464        wl_save_options($options);
     465
    293466    }
    294467   
     
    307480       
    308481        $excerpt = trim_excerpt($queryResult[0]->post_content, $queryResult[0]->post_excerpt); 
    309         $excerpt = str_replace( '[welocally/]', '', $excerpt );
     482        $excerpt = WelocallyPlaces_Tag::searchAndReplace($excerpt, create_function('$tag,$tag_str', 'return "";'));
    310483        $excerpt = str_replace( '\'', '', $excerpt );
    311484        $excerpt = trim( preg_replace( '/\s+/', ' ', $excerpt ) );
     485        $excerpt = "";
    312486       
    313487        return $excerpt;
     
    345519    }
    346520   
    347    
    348    
    349 
     521    function get_post_places($post_id=0) {
     522        global $wlPlaces;
     523       
     524        if (!$post_id) $post_id = get_the_ID();
     525       
     526        return $wlPlaces->getPostPlaces($post_id);
     527    }
     528   
     529    function get_post_places_meta($post_id=0) {
     530        global $wlPlaces;
     531       
     532        if (!$post_id) $post_id = get_the_ID();
     533       
     534        return $wlPlaces->getPostPlacesMeta($post_id);
     535    }
     536   
     537// functions for get template
     538    function wl_places_get_template_map_widget(){
     539        $templateOverride = locate_template( array( 'places/places-map-widget-display.php' ) );
     540        $theme_dir = get_theme_view_dir(); 
     541        return $templateOverride ? $templateOverride : dirname( __FILE__ ).'/views/themes/'.$theme_dir.'/welocally-places-map-widget-display.php';
     542    }
     543   
     544    function wl_places_get_template_list_widget(){
     545        $templateOverride = locate_template( array( 'places/places-map-widget-display.php' ) );
     546        $theme_dir = get_theme_view_dir(); 
     547        return  $templateOverride ? $templateOverride : dirname( __FILE__ ).'/views/themes/'.$theme_dir.'/welocally-places-list-widget-display.php';
     548    }
     549   
     550    function wl_places_get_template_category(){
     551        global $wlPlaces;
     552        $cat_map_layout_type = $wlPlaces->getSingleOption('cat_map_layout');
     553                   
     554        if($cat_map_layout_type == 'none'
     555            || is_Feed()) {
     556            return;
     557        }
     558           
     559        $theme_dir = get_theme_view_dir(); 
     560        return dirname( __FILE__ ) . '/views/themes/'.$theme_dir.'/category-places-map.php';
     561    }
    350562}
  • welocally-places/trunk/views/includes/category-map-include.php

    r476641 r514360  
    2525   
    2626    #content-body ul, #content-body ol { margin: 0px;  }
    27 
    2827
    2928    #selectable .ui-selecting { background: #C4C4C4; }
     
    146145        directionsicon,
    147146        showLink,
    148         link,
    149147        showThumb,
    150148        thumbUrl);     
     
    188186<?php if(wl_get_option('map_custom_style') != '') : ?> 
    189187
    190     var welocallyMapStyle = <?php printf(base64_decode(wl_get_option("map_custom_style")))  ?>;
    191 
    192     // Create a new StyledMapType object, passing it the array of styles,
    193     // as well as the name to be displayed on the map type control.
    194     var styledMapType = new google.maps.StyledMapType(welocallyMapStyle, {name: "Custom"});
    195    
    196     var mapOptions = {
    197       mapTypeControlOptions: {
    198         mapTypeIds: ['welocally_style']
    199       }
    200     };
    201    
     188    var welocallyMapStyle = <?php printf(wl_get_option("map_custom_style"))  ?>;
     189   
     190    var mapOptions = {
     191        zoom : 16,
     192        center : latlng,
     193        mapTypeId: google.maps.MapTypeId.ROADMAP,
     194        styles: welocallyMapStyle
     195    };
     196 
    202197    wl_map_main = new google.maps.Map(document.getElementById("map_canvas"),
    203198        mapOptions);
    204199       
    205     //Associate the styled map with the MapTypeId and set it to display.
    206     wl_map_main.mapTypes.set('welocally_style', styledMapType);
    207     wl_map_main.setMapTypeId('welocally_style'); 
     200    WELOCALLY.places.map.setMapEvents(wl_map_main);
     201   
     202   
     203
     204
    208205
    209206<?php else:?>   
     
    215212    wl_map_main = new google.maps.Map(document.getElementById("map_canvas"),
    216213        mapOptions);
    217 
     214       
     215    WELOCALLY.places.map.setMapEvents(wl_map_main);
     216   
    218217
    219218<?php  endif; ?>
     
    224223<?php
    225224$index = 0;
    226 $cat_ID = get_query_var( 'cat' );           
     225$cat_ID = get_query_var( 'cat' );
    227226$places_in_category_posts = get_places_posts_for_category($cat_ID);
    228 foreach( $places_in_category_posts as $post ) {
     227
     228foreach( $places_in_category_posts as $post ):
     229    $places = get_post_places($post->ID);
     230   
     231    foreach ($places as $place):
    229232?> 
    230233<?php $index=$index+1; ?>   
     
    243246   
    244247
    245     places[<?php echo $index; ?>] = jQuery.parseJSON( '<?php echo $bodytag = str_replace("'", "\'", get_post_meta( $post->ID, '_PlaceSelected', true )); ?>' );
    246     var latlng = new google.maps.LatLng(places[<?php echo $index; ?>].latitude, places[<?php echo $index; ?>].longitude);
     248    places[<?php echo $index; ?>] = <?php echo json_encode($place); ?>;
     249    var latlng = new google.maps.LatLng(places[<?php echo $index; ?>].geometry.coordinates[1], places[<?php echo $index; ?>].geometry.coordinates[0]);
    247250    bounds.extend(latlng);
    248251   
     
    293296   
    294297<?php
    295 }
     298    endforeach;
     299endforeach;
    296300?>     
    297301
     
    307311    jQuery( "#selectable" ).selectable({
    308312           selected: function(event, ui) {
    309                 console.log("selected");
     313               
    310314                var index = ui.selected.id.replace("item","");
    311315                var selectedItem = items[index];
    312                 var placeLatLng = new google.maps.LatLng(selectedItem.place.latitude, selectedItem.place.longitude);
     316                var placeLatLng = new google.maps.LatLng(selectedItem.place.geometry.coordinates[1], selectedItem.place.geometry.coordinates[0]);
    313317                wl_map_main.panTo(placeLatLng);
    314                
    315                 boxText.innerHTML =
    316                     buildContentForInfoWindow(
     318                           
     319                var contentsBox = jQuery(document.createElement('div'));
     320                   
     321                var contents = buildContentForInfoWindow(
     322                    WELOCALLY.places.map.infobox.baseWidth,
    317323                    selectedItem.place, ",",
    318324                    selectedItem.marker.webicon,
     
    321327                    selectedItem.marker.linkUrl,
    322328                    selectedItem.marker.showThumb,
    323                     selectedItem.marker.thumbUrl);
     329                    selectedItem.marker.thumbUrl,
     330                    WELOCALLY.places.map.infobox.thumbMaxSize);
     331           
     332                jQuery(contentsBox).html(contents);
     333               
     334                boxText.innerHTML = contents;
     335               
     336                WELOCALLY.places.map.infobox.setOffset(contentsBox,ib);
     337       
    324338                ib.open(wl_map_main, selectedItem.marker);
     339                ib.show();
     340                ib_widget.hide();
     341               
     342                jQuery('#info-contents-box ul li a').css('background','none').css('padding','0px');
     343                           
    325344                lastindex= index;
    326345           },
  • welocally-places/trunk/views/includes/infobox-map-include.php

    r473697 r514360  
    1111            ,disableAutoPan: false
    1212            ,maxWidth: 0
    13             ,pixelOffset: new google.maps.Size(-170, 0)
     13            ,pixelOffset: new google.maps.Size(0, 0)
    1414            ,zIndex: null
    1515            ,boxStyle: {
    16                 background: "url('<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/tipbox_340.png') no-repeat",
    1716                opacity: 0.85,
    18                 width:"340px"
    1917             }
    2018            ,closeBoxMargin: "10px 2px 2px 2px"
     
    3230            ,disableAutoPan: false
    3331            ,maxWidth: 0
    34             ,pixelOffset: new google.maps.Size(-90, 0)
     32            ,pixelOffset: new google.maps.Size(0, 0)
    3533            ,zIndex: null
    3634            ,boxStyle: {
    37                 background: "url('<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/tipbox_180.png') no-repeat",
    3835                opacity: 0.85,
    39                 width:"180px"
    4036             }
    4137            ,closeBoxMargin: "10px 2px 2px 2px"
  • welocally-places/trunk/views/includes/places-list-include.php

    r463355 r514360  
    2424<script type="text/javascript" charset="utf-8">
    2525
    26 
    2726jQuery(document).ready(function(jQuery) {
    28    
    29    
    30    
     27       
    3128     if (typeof(jQuery.fn.parseJSON) == "undefined" || typeof(jQuery.parseJSON) != "function") {
    3229
     
    5047        });
    5148    }   
    52     var placeSelected = jQuery.parseJSON( '<?php echo $bodytag = str_replace("'", "\'", $PlaceSelected); ?>' );
    53     var catsDiv = jQuery('#plugin-place-category<?php echo $post->ID; ?>');
     49    var placeSelected = <?php echo json_encode($PlaceSelected); ?>;
     50
     51    var catsDiv = jQuery("*[id\^='plugin-place-category<?php echo $index;?>']");
     52    var placeDiv = jQuery("*[id\^='plugin-place<?php echo $index;?>']");   
    5453   
    55     jQuery('#plugin-place<?php echo $post->ID; ?>').html(
     54    jQuery(placeDiv).html(
    5655        buildContentForInfoForList(
    5756            placeSelected,
    58             <?php echo $post->ID; ?>,
     57            <?php echo $index; ?>,
    5958            '<?php echo get_permalink( $post->ID ); ?>',
    6059            '<?php echo wl_get_option("map_icon_web"); ?>',
    6160            '<?php echo wl_get_option("map_icon_directions"); ?>'));
    62            
    63     jQuery('#plugin-place-links<?php echo $post->ID; ?>').before(catsDiv);
     61               
     62    for (var i=0; i<placeDiv.length; i++) {
     63        jQuery(placeDiv[i]).find('#plugin-place-links<?php echo $index; ?>').before(catsDiv[i]);
     64    }
    6465    catsDiv.show();
    6566   
  • welocally-places/trunk/views/includes/places-map-include.php

    r473697 r514360  
    4545}
    4646.wl-place-widget-address{ }
    47 
    48 
    49 
    5047</style>
    5148
     
    5451var wl_map_widget;
    5552
     53
    5654jQuery(document).ready(function(jQuery) {
     55   
    5756   
    5857     if (typeof(jQuery.fn.parseJSON) == "undefined"
     
    7877        });
    7978    }   
    80 
     79   
     80    jQuery('#map_widget_container ul').css('list-style-type','none');
     81    jQuery('#map_widget_container ul').find('*')
     82        .css('padding','0x')
     83        .css('margin','0x');
     84    jQuery('#info-contents-box').css('line-height','15px');
     85   
     86    //#sidebar .widget ul li a {background:url(images/ico-meta.gif) no-repeat 0 8px; padding:4px 0 4px 15px; line-height:16px;}
     87   
    8188   
    8289    //setup the bounds
    8390    var bounds = new google.maps.LatLngBounds();
    8491
    85     jQuery('#map_canvas_widget').height( 400 );
     92    //find all  map widgets
     93    var map_canvas_widgets = jQuery("*[id\^='map_canvas_widget']");
     94   
     95    jQuery(map_canvas_widgets).height( 400 );
    8696    jQuery('#map_canvas_widget img').css('max-width' ,'1030px');
    8797    jQuery('.gmnoprint img').css('max-width' ,'1030px');
     
    90100
    91101<?php if(wl_get_option('map_custom_style') != '') : ?> 
    92 
    93     var welocallyMapStyle = <?php printf(base64_decode(wl_get_option("map_custom_style")))  ?>;
    94 
    95     // Create a new StyledMapType object, passing it the array of styles,
    96     // as well as the name to be displayed on the map type control.
    97     var styledMapType = new google.maps.StyledMapType(welocallyMapStyle, {name: "Custom"});
    98    
     102    //make the style map
     103    var welocallyMapStyle = <?php printf(wl_get_option("map_custom_style"))  ?>;
     104
    99105    var mapOptions = {
    100       mapTypeControlOptions: {
    101         mapTypeIds: ['welocally_style']
    102       }
     106        mapTypeId: google.maps.MapTypeId.ROADMAP,
     107        styles: welocallyMapStyle,
     108        draggableCursor: 'url(http://maps.google.com/mapfiles/openhand.cur)'
    103109    };
    104110   
    105     wl_map_widget = new google.maps.Map(document.getElementById("map_canvas_widget"),
    106         mapOptions);
    107        
    108     //Associate the styled map with the MapTypeId and set it to display.
    109     wl_map_widget.mapTypes.set('welocally_style', styledMapType);
    110     wl_map_widget.setMapTypeId('welocally_style'); 
     111    var wl_map_widget = new Array();
     112   
     113    for (var i=0; i<map_canvas_widgets.length; i++) {
     114        wl_map_widget[i] = new google.maps.Map(
     115            map_canvas_widgets[i],
     116            mapOptions);
     117           
     118        WELOCALLY.places.map.setMapEvents(wl_map_widget[i]);
     119       
     120    }
     121   
    111122
    112123<?php else:?>   
    113124   
    114125    var mapOptions = {
    115       mapTypeId: google.maps.MapTypeId.ROADMAP
     126      mapTypeId: google.maps.MapTypeId.ROADMAP,
     127      draggableCursor: 'url(http://maps.google.com/mapfiles/openhand.cur), move'
    116128    };
    117    
    118     wl_map_widget = new google.maps.Map(document.getElementById("map_canvas_widget"),
    119         mapOptions);
    120        
    121 
     129
     130    var wl_map_widget = new Array();
     131   
     132    for (var i=0; i<map_canvas_widgets.length; i++) {
     133   
     134        wl_map_widget[i] = new google.maps.Map(
     135            map_canvas_widgets[i],
     136            mapOptions);
     137       
     138        WELOCALLY.places.map.setMapEvents(wl_map_widget[i]);
     139       
     140       
     141    }
    122142
    123143<?php  endif; ?>
    124 
    125    
    126144
    127145    var places = new Array();
     
    129147<?php
    130148$index = 0;
    131 foreach( $posts as $post ) { ?>
    132     places[<?php echo $index; ?>] =
    133         jQuery.parseJSON(
    134             '<?php echo $bodytag = str_replace("'", "\'", get_post_meta( $post->ID, '_PlaceSelected', true )); ?>' );       
    135    
    136     var latlng = new google.maps.LatLng(places[<?php echo $index; ?>].latitude, places[<?php echo $index; ?>].longitude);
     149foreach( $posts as $post ) {
     150    $places = get_post_places($post->ID);
     151   
     152    foreach ($places as $place):
     153?>
     154    places[<?php echo $index; ?>] = <?php echo json_encode($place) ; ?>;
     155   
     156    var latlng = new google.maps.LatLng(places[<?php echo $index; ?>].geometry.coordinates[1], places[<?php echo $index; ?>].geometry.coordinates[0]);
    137157    bounds.extend(latlng);
    138158   
     
    148168    directionsicon
    149169    */
    150     var item<?php echo $index; ?> =  addItemMarker(
    151         'places-map',
    152         <?php echo $index; ?>,
    153         places[<?php echo $index; ?>],
    154         wl_map_widget,
    155         '<?php echo wl_get_option("map_default_marker") ?>',
    156         '<?php echo str_replace("'", "\'",$post->post_name); ?>',
    157         '<?php echo get_post_permalink( $post->ID ); ?>',
    158         '<?php echo str_replace("'", "\'",wl_get_post_excerpt( $post->ID )); ?>',   
    159         '<?php echo wl_get_option("map_icon_web"); ?>',
    160         '<?php echo wl_get_option("map_icon_directions"); ?>',
    161         false,
    162         '',
    163         false,
    164         ''     
    165         );
    166        
     170    for (var i=0; i<wl_map_widget.length; i++) {
     171        var item<?php echo $index; ?> =  addItemMarker(
     172            'places-map',
     173            <?php echo $index; ?>,
     174            places[<?php echo $index; ?>],
     175            wl_map_widget[i],
     176            '<?php echo wl_get_option("map_default_marker") ?>',
     177            '<?php echo str_replace("'", "\'",$post->post_name); ?>',
     178            '<?php echo get_post_permalink( $post->ID ); ?>',
     179            '<?php echo str_replace("'", "\'",wl_get_post_excerpt( $post->ID )); ?>',   
     180            '<?php echo wl_get_option("map_icon_web"); ?>',
     181            '<?php echo wl_get_option("map_icon_directions"); ?>',
     182            false,
     183            false,
     184            ''     
     185            );
     186    }   
    167187<?php
    168188    $index=$index+1;
     189    endforeach;
    169190}
    170191?> 
    171192
     193    for (var i=0; i<wl_map_widget.length; i++) {
    172194    //init map with bounds   
    173     if(<?php echo $index; ?>==1){
    174         wl_map_widget.setCenter(latlng);
    175         wl_map_widget.setZoom(14);
    176     } else {
    177         wl_map_widget.fitBounds(bounds);
    178     }
     195        if(<?php echo $index; ?>==1){
     196            wl_map_widget[i].setCenter(latlng);
     197            wl_map_widget[i].setZoom(14);
     198        } else {
     199            wl_map_widget[i].fitBounds(bounds);
     200        }
     201    }
    179202   
    180203});
  • welocally-places/trunk/views/place-content-template.php

    r466267 r514360  
    1 <script type="text/javascript" charset="utf-8">
     1<script type="text/javascript">
     2jQuery(document).ready(function() {
     3    jQuery('.place-links-all').find('*')
     4        .css('margin','0px')
     5        .css('padding','0px');
     6       
     7    jQuery('.wl-place-content').filter(function(){
     8        jQuery(this).css('width',jQuery(this).parent().width()-5); 
     9    });
    210
    3 var map_post = null;
    4 jQuery(document).ready(function(jQuery) {
    5    
    6     //themes can screw up google maps
    7     jQuery('#map_canvas_post img').css('max-width' ,'1030px');
    8     jQuery('.gmnoprint img').css('max-width' ,'1030px');
    9    
    10    
    11      if (typeof(jQuery.fn.parseJSON) == "undefined" || typeof(jQuery.parseJSON) != "function") {
    12 
    13         //extensions, this is because prior to 1.4 there was no parse json function
    14         jQuery.extend({
    15             parseJSON: function( data ) {
    16                 if ( typeof data !== "string" || !data ) {
    17                     return null;
    18                 }   
    19                 data = jQuery.trim( data );   
    20                 if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
    21                     .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
    22                     .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {   
    23                     return window.JSON && window.JSON.parse ?
    24                         window.JSON.parse( data ) :
    25                         (new Function("return " + data))();   
    26                 } else {
    27                     jQuery.error( "Invalid JSON: " + data );
    28                 }
    29             }
    30         });
    31     }   
    32    
    33     var place = jQuery.parseJSON( '%2$s' );
    34    
    35     var showMap = %3$s;
    36     var customStyle = %4$s;
    37    
    38     jQuery('#place-name-%1$d').html(place.name);
    39    
    40     jQuery('#place-address-%1$d').html(
    41         place.address+", "+
    42         place.city+" "+
    43         place.state+" "+
    44         place.postalCode);
    45            
    46     if(place.phone != null) {
    47         jQuery('#place-phone-%1$d').html(place.phone);
     11});
     12</script>
     13<style>
     14    #place-details { width: 100%; display: none; background-color: #eeeeee; }
     15    #sp-click-action-call { width: 100%; background-color: #eeeeee; }
     16    .simple_grey_italic {
     17        font-size:1.2em;
     18        font-style:italic;
     19        font-weight:normal;
     20        color: #333333;
     21        font-family:Adobe Garamond Pro, Garamond, Palatino, Palatino Linotype, Times, Times New Roman, Georgia, serif;
    4822    }
    4923   
    50     if(place.website != null && place.website != '' ) {
    51         var website = place.website;
    52         if(place.website.indexOf('http://') == -1) {
    53             website = 'http://'+place.website;
    54         }
    55         jQuery('#place-website-%1$d')
    56                 .html(
    57                     '<table><tr><td class="wl-place-link-item"><a href="'+
    58                     website+'">'+
    59                     '<img src="%6$s" border="0"/></a></td>'+
    60                     '<td class="wl-place-link-item"><a href="'+
    61                     website+'" target="_new">website</a></td></tr></table>');
    62     } else if(place.url != null && place.url != '') {
    63         var website = place.url;
    64         if(place.url.indexOf('http://') == -1) {
    65             website = 'http://'+place.url;
    66         }                   
    67         jQuery('#place-website-%1$d')
    68             .html(
    69                 '<table><tr><td class="wl-place-link-item"><a href="'+
    70                 website+'">'+
    71                 '<img src="%6$s" border="0"/></a></td>'+
    72                 '<td class="wl-place-link-item"><a href="'+
    73                 website+'" target="_new">website</a></td></tr></table>');
     24    img.wl-link-image {
     25        /*float: right;*/
     26        margin: 4px;
     27        border:0px;
    7428    }
    7529   
    76     if(place.city != null && place.state != null){
    77             var qS = place.city+" "+place.state;
    78             if(place.address != null)
    79                 qs=place.address+" "+qS;
    80             if(place.postalCode != null)
    81                 qs=qs+" "+place.postalCode;
    82             var qVal = qs.replace(" ","+");
     30ul.wl-place-links { padding-left: 0px; }
     31
     32#details-place-name{ margin: 3px;}
     33
     34#details-place-excerpt{ margin: 3px 3px 10px 3px;}
     35
     36.sidebar-item li {
     37    list-style: none;
     38 }
     39
     40/* override the font style   */
     41.content-sidebar ul li a:hover, .content-sidebar .recentcomments a:hover {
     42color: #<?php echo wl_get_option("color_place_name", "000000"); ?>;
     43}
     44.wl-place-name {
     45    font-family: <?php echo wl_get_option("font_place_name", "Sorts Mill Goudy"); ?>;
     46    color: #<?php echo wl_get_option("color_place_name", "000000"); ?>;
     47}
     48.wl-place-name a {
     49    font-family: <?php echo wl_get_option("font_place_name", "Sorts Mill Goudy"); ?>;
     50    color: #<?php echo wl_get_option("color_place_name", "000000"); ?>;
     51}
     52
     53.wl-place-widget-name{ }
     54.wl-place-address {
     55    font-family: <?php echo wl_get_option("font_place_address", "Sorts Mill Goudy"); ?>;
     56    color: #<?php echo wl_get_option("color_place_address", "000000"); ?>;
     57}
     58.wl-place-widget-address{ }
     59</style>
     60<div id="wl-place-content-<?php echo $t->uid; ?>" class="wl-place-content">
     61    <div class="map_canvas_post"></div>
     62    <div class="wl-place-name" id="place-name-<?php echo $t->uid; ?>"></div>
     63    <div class="wl-place-address" id="place-address-<?php echo $t->uid; ?>"></div>
     64    <div class="wl-place-phone" id="place-phone-<?php echo $t->uid; ?>"></div> 
     65    <div class="place-links-all">
     66        <ul class="wl-place-links">
     67            <li class="wl-place-links-lines" >
     68                <span class="wl-place-website" id="place-website-<?php echo $t->uid; ?>"></span>
     69            </li>
     70            <li class="wl-place-links-lines" >
     71                <span class="wl-place-driving" id="place-driving-<?php echo $t->uid; ?>"></span>
     72            </li>
     73            <li class="wl-place-links-lines" id="place-embed">
     74                <table>
     75                    <tbody>
     76                    <tr>
     77                        <td class="wl-place-link-item">
     78                        <img width="16" height="16"
     79                            src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/we_16.png" alt="" title=""/></td>
     80                        <td class="wl-place-link-item"><a id="share-link-<?php echo $t->uid; ?>" href="#">embed</a></td>
     81                    </tr>
     82                    </tbody>
     83                </table>
     84                <script>
     85                jQuery("#share-link-<?php echo $t->uid; ?>").click(function () {   
     86                  jQuery("#place-tag-field-<?php echo $t->uid; ?>").val(WELOCALLY.places.tag.makePlaceTag(<?php echo $t->placeJSON; ?>)); 
     87                  jQuery("#share-tag-<?php echo $t->uid; ?>").toggle();
     88                  return false;
     89                });         
     90                </script>
     91            </li>
     92        </ul>
     93        <div class="share-place-tag" id="share-tag-<?php echo $t->uid; ?>">
     94        <table width="100%">
     95                <tr><td colspan="2"><input class="share-place-tag-tagtext" type="text" id="place-tag-field-<?php echo $t->uid; ?>"></input></td></tr>
     96                <tr><td align="left"><div>Place this tag in your own <a href="http://welocally.com/?page_id=2">Welocally Places</a> powered <a href="http://wordpress.org/extend/plugins/welocally-places/">wordpress</a> site.</div></td>
     97                <td align="right"><a href="http://welocally.com/?page_id=2"><img width="95" height="20"
     98                src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/places_powered.png"
     99                alt="" title="Powered by Welocally Places"/></a></td></tr>
     100            </table>
    83101           
    84             jQuery('#place-driving-%1$d')
    85                 .html(
    86                     '<table><tr><td class="wl-place-link-item"><a href="http://maps.google.com/maps?f=d&source=s_q&hl=en&geocode=&q='+
    87                 qVal+'" target="_new"><img src="%7$s"/></a></td>'+
    88                     '<td class="wl-place-link-item"><a href="http://maps.google.com/maps?f=d&source=s_q&hl=en&geocode=&q='+
    89                 qVal+'" target="_new">directions</a></td></tr></table>');
    90      }
    91      
    92      if(showMap && customStyle ){
    93         var latlng = new google.maps.LatLng(place.latitude, place.longitude);
    94    
    95         var welocallyMapStyle = %5$s;
    96        
    97        
    98         // Create a new StyledMapType object, passing it the array of styles,
    99         // as well as the name to be displayed on the map type control.
    100         var styledMapType = new google.maps.StyledMapType(welocallyMapStyle,
    101             {name: "Custom"});
    102        
    103        
    104         var mapOptions = {
    105           zoom: 16,
    106           center: latlng,
    107           mapTypeControlOptions: {
    108             mapTypeIds: ['welocally_style']
    109           }
    110         };
    111        
    112         map_post = new google.maps.Map(document.getElementById("map_canvas_post"),
    113             mapOptions);
    114            
    115         //Associate the styled map with the MapTypeId and set it to display.
    116         map_post.mapTypes.set('welocally_style', styledMapType);
    117         map_post.setMapTypeId('welocally_style');
    118        
    119        
    120         //home location
    121         var mMarker = new google.maps.Marker({
    122             position: latlng,
    123             map: map_post,
    124             icon: '%14$s'
    125         });
    126        
    127         jQuery('#map_canvas_post').show();
    128      
    129      } else if(showMap && !customStyle ){
    130         var latlng = new google.maps.LatLng(place.latitude, place.longitude);
    131    
    132         var mapOptions = {
    133           zoom: 12,
    134           center: latlng,
    135           mapTypeId: google.maps.MapTypeId.ROADMAP
    136         };
    137        
    138         map_post = new google.maps.Map(document.getElementById("map_canvas_post"),
    139             mapOptions);
    140    
    141         //home location
    142         var mMarker = new google.maps.Marker({
    143             position: latlng,
    144             map: map_post,
    145             icon: '%14$s'
    146         });
    147        
    148         jQuery('#map_canvas_post').show();
    149      }
    150    
    151 });
     102        </div> 
     103    </div>
    152104
     105</div>
     106<script type="text/javascript" charset="utf-8">
     107    WELOCALLY.places.tag.insertPlace('wl-place-content-<?php echo $t->uid; ?>',
     108                         <?php echo $t->placeJSON; ?>,
     109                         <?php echo json_encode($t->options); ?>);
    153110</script>
    154 <div id="wl-place-content">
    155     <div id="map_canvas_post"></div>
    156     <div class="wl-place-name" id="place-name-%1$d"></div>
    157     <div class="wl-place-address" id="place-address-%1$d"></div>
    158     <div class="wl-place-phone" id="place-phone-%1$d"></div>
    159    
    160     <ul>
    161         <li class="wl-place-links-lines" >
    162             <span id="place-website-%1$d"></span>
    163         </li>
    164         <li class="wl-place-links-lines" >
    165             <span id="place-driving-%1$d"></span>
    166         </li>
    167     </li>
    168 </div>
  • welocally-places/trunk/views/places-meta-box.php

    r476641 r514360  
    1 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
    2 <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/smoothness/jquery-ui.css" type="text/css" />
    3 <script type="text/javascript" charset="utf-8">
     1<?php global $post; ?>
     2<script type="text/javascript">
     3if (!window.WELOCALLY) {
     4    window.WELOCALLY = {
     5       
     6    };
     7}
     8
     9//this can go farther
     10WELOCALLY.meta = {
     11    post: {
     12        type: '<?php echo $post->post_type; ?>',
     13        id: '<?php echo $post->ID; ?>'
     14    }
     15}
     16
    417var jsonObjFeatures = []; //declare features array
     18var markersArray = [];
    519var selectedFeatureIndex = 0;
     20var selectedClassifierLevel='';
    621var selectedCategories='';
    7 var isSelected = false;
    8    
    9 var tags=[<?php $tags = wp_get_post_tags($post->ID);
    10 foreach( $tags as $tag ){ 
    11     echo "'";
    12     print_r(str_replace("'", "\'",$tag->name));
    13     echo "',";
    14 } ?>];
    15 
    16 
    17 function getLocationsByAddress(address, keyword, radiusKm) {   
    18     jQuery('#welocally-post-error').removeClass('welocally-error welocally-update error updated fade');
    19     jQuery('#welocally-post-error').html('<em>Loading Places...</em>');
     22var map;
     23var selectedGeocode;
     24var selectedPlace = {
     25    properties: {},
     26    type: 'Place',
     27    classifiers: [
     28        {
     29            type: '',
     30            category: '',
     31            subcategory: ''
     32        }
     33    ],
     34    geometry: {
     35            type: "Point",
     36            coordinates: []
     37    }
     38};
     39
     40var activityType;
     41
     42var jqxhr;
     43
     44function setStatus(message, type, showloading){
     45    jQuery('#welocally-post-error').html('');
     46    jQuery("#welocally-post-error").removeClass();
     47   
     48    if(type=='update'){
     49        jQuery('#welocally-post-error').addClass('welocally-update');
     50    } else if(type=='error'){
     51        jQuery('#welocally-post-error').addClass('welocally-error');
     52    } else if(type=='message'){
     53        jQuery('#welocally-post-error').addClass('welocally-message');
     54    }
     55   
     56    if(showloading){
     57        jQuery('#welocally-post-error').append('<img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/ajax-loading.gif" alt="" title=""/>');
     58    }
     59   
     60    jQuery('#welocally-post-error').append('<em>'+message+'</em>');
     61   
     62    if(message != ''){
     63        jQuery('#welocally-post-error').show();
     64    } else {
     65        jQuery('#welocally-post-error').hide();
     66    }   
     67   
     68}
     69
     70function addMarker(map_marker, location) {
     71  var marker = new google.maps.Marker({
     72    position: location,
     73    map: map_marker
     74  });
     75  markersArray.push(marker);
     76}
     77
     78// Removes the overlays from the map, but keeps them in the array
     79function clearOverlays() {
     80  if (markersArray) {
     81    for (i in markersArray) {
     82      markersArray[i].setMap(null);
     83    }
     84  }
     85}
     86
     87// Shows any overlays currently in the array
     88function showOverlays() {
     89  if (markersArray) {
     90    for (i in markersArray) {
     91      markersArray[i].setMap(map);
     92    }
     93  }
     94}
     95
     96// Deletes all markers in the array by removing references to them
     97function deleteOverlays() {
     98  if (markersArray) {
     99    for (i in markersArray) {
     100      markersArray[i].setMap(null);
     101    }
     102    markersArray.length = 0;
     103  }
     104}
     105
     106
     107function searchLocations(location, queryString, radiusKm) {
     108    setStatus('Loading Places...', 'message', true);
     109   
    20110    jQuery('#selectable').empty();
    21111    jsonObjFeatures = [];
    22    
    23 
    24        
     112           
     113   
    25114    var options = {
    26115        action: 'get_places',
    27         siteKey : '<?php echo wl_get_option('siteKey',null) ?>',
    28         siteToken : '<?php echo wl_get_option('siteToken',null) ?>',
    29         baseurl : '<?php echo wl_get_option('siteHome',get_bloginfo('home')); ?>',
    30         address : address.replace(/'/g, ''),
    31         radius: radiusKm,
    32         query : keyword.replace(/'/g, '')
     116        q: queryString,
     117        loc: location.lat()+'_'+location.lng(),
     118        radiusKm: 20
    33119    };
    34120               
    35121    jQuery.ajax({
    36       type: 'POST',
     122      type: 'GET',
    37123      url: ajaxurl,
    38       dataType: 'json',
    39124      data: options,
    40       error : function(jqXHR, textStatus, errorThrown) {
    41             console.error(textStatus);
    42             jQuery('#welocally-post-error').html('ERROR : '+textStatus);
    43             jQuery('#welocally-post-error').addClass('welocally-error error fade');
     125      dataType : 'json',
     126      beforeSend: function(jqXHR){
     127        jqxhr = jqXHR;
     128      },
     129      //dont know why success is not working on empty results
     130      statusCode: {
     131        200: function(data, textStatus, jqXHR) {
     132            if(data != null && data.length == 0) {
     133                setStatus('Sorry no places were found that match your query.', 'update', false);
     134                jQuery('#add-place-section').append(jQuery('#cancel-finder-workflow'));
     135                jQuery('#place-selector').append(jQuery('#add-place-section'));
     136                jQuery('#add-place-section').show();
     137                           
     138            }
     139        }
     140      },
     141      error : function(jqXHR, textStatus, errorThrown) {           
     142            if(textStatus != 'abort'){
     143                setStatus('ERROR : '+textStatus+" there may been a network error or a problem with your settings.", 'error', false);
     144                jQuery('#add-place-section').append(jQuery('#cancel-finder-workflow'));
     145                jQuery('#place-selector').append(jQuery('#add-place-section'));
     146                jQuery('#add-place-section').show();
     147               
     148            }   else {
     149                console.log(textStatus);
     150            }       
    44151      },
    45152      success : function(data, textStatus, jqXHR) {
    46             jQuery('#welocally-post-error').html('');
    47 
    48             if(data != null && data.places != null && data.places.length == 0) {
    49                 jQuery('#welocally-post-error').append('<div class="welocally-context-help"><a href="http://www.welocally.com/wordpress/?page_id=104#info_201" target="_new"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/context_help_16.png" alt="" title="Get help" height="16px" width="16px" border="0px"/></a></div>');
    50                 jQuery('#welocally-post-error').append('Sorry no places were found that match your query, try again or add this as a new place.');
    51                 jQuery('#welocally-post-error').addClass('welocally-update updated fade');
     153
     154            setStatus('', 'message', false);
     155                       
     156            if(data != null && data.length == 0) {
     157                setStatus('Sorry no places were found that match your query.', 'update', false);
     158                jQuery('#add-place-section').append(jQuery('#cancel-finder-workflow'));
     159                jQuery('#place-selector').append(jQuery('#add-place-section'));
     160                jQuery('#add-place-section').show();
    52161               
    53             } else if(data != null && data.places != null && data.places.length > 0) {
    54                 jQuery.each(data.places, function(i,item){
     162            } else if(data != null && data.length > 0) {
     163                jQuery.each(data, function(i,item){
    55164                    jsonObjFeatures.push(item);             
    56                     jQuery('#selectable').append(buildListItemForPlace(item,i));
    57                     jQuery("#results").show(); 
     165                    jQuery('#selectable').append(buildListItemForPlace(item,i));               
    58166                });
    59             } else if(data != null && data.places == null && data.errors != null) {
     167                jQuery('#search-geocoded-section').append(jQuery('#results'));
     168                jQuery('#add-place-section').append(jQuery('#cancel-finder-workflow'));     
     169                jQuery('#results').append(jQuery('#add-place-section'));                                           
     170                jQuery("#results").show(); 
     171                jQuery('#add-place-section').show();
     172               
     173            } else if(data != null && data.errors != null) {
    60174           
    61175                buildErrorMessages(data.errors);   
    62176                   
    63             } else if(data == null) {
    64                
    65                 var errors = new Array();
    66                 var errorEmpty = {
    67                     errorCode: 108,
    68                     errorMessage: "Problem connecting to Welocally, please contact us."
    69                 };
    70                 errors.push(errorEmpty);
    71            
    72                 buildErrorMessages(errors);
    73                    
     177            } else {
     178                setStatus('There was a problem, please check your settings and network.', 'error', false);
     179                jQuery('#add-place-section').append(jQuery('#cancel-finder-workflow'));
     180                jQuery('#place-selector').append(jQuery('#add-place-section'));
     181                jQuery('#add-place-section').show();
    74182            }
    75183      }
    76184    });
    77    
    78    
     185   
    79186}
    80187
    81188function buildListItemForPlace(place,i) {
    82         var itemLabel = '<b>'+place.name+'</b>';
    83         if (place.address) {
    84             itemLabel += "<br>" + place.address;
     189        var itemLabel = '<b>'+place.properties.name+'</b> - '+place.distance.toFixed(2)+' km';
     190        if (place.properties.address) {
     191            itemLabel += "<br>" + place.properties.address+" "+
     192                place.properties.city+" "+place.properties.province+" "
     193                +place.properties.postcode;
    85194        }
    86195        return '<li class=\"ui-widget-content\" id="f'+i+'" title="select place">'+itemLabel+'</li>';
    87196}
    88197
    89 function buildSelectedInfoForPlace(place) {
    90         var itemLabel = '<b>'+place.name+'</b>';
    91         if (place.address) {
    92             itemLabel += "<br>" + place.address;
     198function buildSelectedInfoForPlace(place) { 
     199        var itemLabel = '<b>'+place.properties.name+'</b>';
     200        if (place.properties.address) {
     201            itemLabel += "<br>" + place.properties.address;
    93202        }
    94203        return '<div class=\"selected-place-info\">'+itemLabel+'</div>';
     
    96205
    97206function buildCategorySelectionsForPlace(place, container) {
     207       
    98208        container.html('');
    99209        var index = -1;
    100         for (category in place.categories) {
    101             index = category;
    102             container.append('<li class=\"ui-widget-content\">'+place.categories[category]+'</li>');
     210       
     211        for (classifier in place.properties.classifiers) {
     212            index = classifier;
     213            container.append('<li class=\"ui-widget-content\">'+place.properties.classifiers[classifier].category+'</li>');
     214            container.append('<li class=\"ui-widget-content\">'+place.properties.classifiers[classifier].subcategory+'</li>');         
    103215        }
    104        
    105         //show if there are items
    106216        if(index != -1){
    107217            jQuery("#categories-choice").show();
    108218        }
    109219       
    110 }
    111 
    112 
    113 function setSelectedPlaceInfo(selectedItem) {
    114     //set selected
    115     isSelected=true;
     220       
     221}
     222
     223function setSelectedPlaceInfo(selectedItem, post) {
     224       
     225    //set form fields for save post
     226    selectedPlace = selectedItem;
     227   
     228    jQuery('#edit-place-name-selected').html(selectedPlace.properties.name);
     229    jQuery('#search-geocoded-address-selected').html(selectedPlace.properties.address+
     230        " "+selectedPlace.properties.city+" "+selectedPlace.properties.province+" "+
     231        selectedPlace.properties.postcode);
     232   
     233    jQuery('#share-meta-tagtext').val(WELOCALLY.places.tag.makePlaceTag(selectedPlace, post)); 
     234    jQuery('#places-tag-selected').show();
     235   
     236    var selectedLocation = new google.maps.LatLng(selectedPlace.geometry.coordinates[1], selectedPlace.geometry.coordinates[0]);       
     237    var myOptions = {
     238        center: selectedLocation,
     239        zoom: 15,
     240        mapTypeId: google.maps.MapTypeId.ROADMAP
     241    };
     242   
     243    if(map==null){
     244        map = new google.maps.Map(document.getElementById("map_canvas"),
     245            myOptions);
     246           
     247        //need to add listeners
     248        WELOCALLY.places.map.setMapEvents(map);     
     249   
     250    } else {
     251        map.setCenter(selectedLocation);
     252    }
     253           
     254    deleteOverlays();                           
     255    addMarker(map,selectedLocation);   
     256   
    116257   
    117258    //hide the selection area
    118259    jQuery("#place-selector").hide();   
    119     jQuery("#add-place-form").hide();   
    120    
     260    jQuery("#edit-place-form").hide(); 
    121261   
    122262    //set the form value
     263    //this is wehere we should build the tag
    123264    jQuery("#place-selected").val(JSON.stringify(selectedItem));
    124265   
    125     //show the *selected* area
    126     var info = buildSelectedInfoForPlace(selectedItem);
    127     jQuery("#selected-place-info").html(info);
    128    
    129     //build the categories
    130     buildCategorySelectionsForPlace(selectedItem, jQuery("#selectable-cat"));
    131    
    132     jQuery("#selected-place").show();   
     266    jQuery('#edit-place-name-selected')
     267   
     268    //show the *selected* area 
     269    jQuery("#selected-place-info").html('');
     270    jQuery("#selected-place-info").append(jQuery('#places-tag-selected'));
     271    jQuery("#selected-place-info").append(jQuery('#edit-place-name-selected'));
     272    jQuery("#selected-place-info").append(jQuery('#search-geocoded-address-selected'));
     273    jQuery("#selected-place-info").append(jQuery('#map_canvas'));
     274   
     275    jQuery("#results").hide();
     276    jQuery("#selected-place").show();       
     277   
     278}
     279
     280function validGeocodeForSearch(geocode) {
     281   
     282    var hasAll = hasType("country", geocode.address_components);
     283    if(hasAll){
     284        hasAll = hasType("locality", geocode.address_components);
     285    }
     286    if(hasAll){
     287        hasAll = hasType("administrative_area_level_1", geocode.address_components);
     288    }
     289    if(hasAll){
     290        hasAll = hasType("postal_code", geocode.address_components);
     291    }
     292    return hasAll;
     293}
     294   
     295function findCategory(categoryName){
     296    var cat;
     297    jQuery.each(currentCategories, function(key, val) {
     298        if(val.name == categoryName) {
     299            cat = val;
     300        }
     301    });
     302    return cat;
     303}
     304
     305function getCategories(type, category) {
     306    jQuery('#edit-place-categories-selection').hide();
     307   
     308    setStatus('Loading Categories...','message', true);
     309               
     310     var options = {
     311        action: 'get_classifiers_types'
     312    };
     313   
     314    var base;
     315    selectedClassifierLevel = 'Type';
     316   
     317    if(type != null && category == null){
     318        base = type;
     319        selectedClassifierLevel = 'Category';
     320       
     321        options.action='get_classifiers_categories';
     322        options.type = type;
     323               
     324    } else if(type != null && category != null){
     325        base = category;
     326        selectedClassifierLevel = 'Subcategory';
     327               
     328        options.action='get_classifiers_subcategories';
     329        options.type = type;
     330        options.category = category;
     331    }
     332   
     333    jqxhr = jQuery.ajax({
     334          type: 'GET',
     335          url: ajaxurl,
     336          data: options,
     337          dataType : 'json',
     338          beforeSend: function(jqXHR){
     339            jqxhr = jqXHR;
     340          },
     341          error : function(jqXHR, textStatus, errorThrown) {
     342            if(textStatus != 'abort'){
     343                setStatus('ERROR : '+textStatus, 'error', false);
     344                jQuery('#edit-place-categories-selection').append(jQuery('#cancel-finder-workflow'));   
     345            }   else {
     346                console.log(textStatus);
     347            }   
     348          },         
     349          success : function(data, textStatus, jqXHR) {
     350           
     351            setStatus('', 'message', false);           
     352                       
     353            jQuery('#edit-place-categories-selection-list').html('');
     354                       
     355            if(base != null && data.length==1){
     356                jQuery('#edit-place-categories-selection-list').append('<li style="display:inline-block;">'+base+'</li>');
     357            }
     358           
     359            if(data != null && data.errors != null) {
     360                buildErrorMessages(data.errors);   
     361                jQuery('#edit-place-categories-selection').append(jQuery('#cancel-finder-workflow'));       
     362            } else {
     363                currentCategories = data;
     364                jQuery.each(data, function(key, val) {
     365                    if(val != null && val != '' ) {
     366                        jQuery('#edit-place-categories-selection-list').append('<li style="display:inline-block;">'+val+'</li>');   
     367                    }
     368                });     
     369                jQuery('#categories-section').show();
     370                jQuery('#edit-place-categories-selection').append(jQuery('#back-action'));     
     371                jQuery('#edit-place-categories-selection').show();
     372               
     373                jQuery('#add-place-actions-section').append(jQuery('#cancel-finder-workflow'));
     374                jQuery('#cancel-finder-workflow').show();   
     375                jQuery('#add-place-actions-section').show();   
     376               
     377            }
     378          }
     379        });
     380}
     381
     382function getShortNameForType(type_name, address_components){
     383    for (componentIndex in address_components) {
     384        var component = address_components[componentIndex];
     385        if(component.types[0] == type_name)
     386            return address_components[componentIndex].short_name;
     387    }
     388    return null;
     389
     390}
     391
     392function hasType(type_name, address_components){
     393    for (componentIndex in address_components) {
     394        var component = address_components[componentIndex];
     395        if(component.types[0] == type_name)
     396            return true;
     397    }
     398    return false;
     399
    133400}
    134401
    135402function buildErrorMessages(errors) {
    136     jQuery('#welocally-post-error').html('');
    137     jQuery('#welocally-post-error').append('<ul>');
     403   
     404    var errorMessageOut = "ERROR: ";
    138405    jQuery.each(errors, function(i,error){
    139         jQuery('#welocally-post-error').append('<li><a href="http://www.welocally.com/wordpress/?page_id=104#error_'+error.errorCode+'" target="_new"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/context_help_16.png" alt="" title="Get help" height="16px" width="16px" border="0px"/></a>  ERROR '+error.errorCode+' : '+error.errorMessage+'</li>');
    140        
    141     });
    142     jQuery('#welocally-post-error').append('</ul>');
    143     jQuery('#welocally-post-error').addClass('welocally-error error fade');
     406        var number = i+1;
     407        errorMessageOut = errorMessageOut+number+". "+error.errorMessage;
     408    });
     409    setStatus(errorMessageOut,'error', false);
    144410}
    145411
     
    147413    jQuery('#welocally-post-error').html('');
    148414    jQuery('#welocally-post-error').append('<ul>');
    149     jQuery('#welocally-post-error').append('<li><a href="http://www.welocally.com/wordpress/?page_id=104#error_104" target="_new"><img src="<?php echo WP_PLUGIN_URL; ?>/welocally-places/resources/images/context_help_16.png" alt="" title="Get help" height="16px" width="16px" border="0px"/></a>  ERROR 104 : Required field is missing, please check all required fields. Missing fields: - '+fields+'</li>');
     415    jQuery('#welocally-post-error').append('<li>error '+fields+' missing</li>');
    150416    jQuery('#welocally-post-error').append('</ul>');
    151     jQuery('#welocally-post-error').addClass('welocally-error error fade');     
    152 }
    153 
    154 function autoload(tags) {
    155     jQuery.each(tags, function(i,tag){
    156         if(tag != 'Autoload' && isSelected){
    157             jQuery("#place-search").val(convertChars(tag));
    158             jQuery("#welocally_default_search_radius").val(<?php echo wl_get_option('default_search_radius',null) ?>);
    159             jQuery("#place-address").val('<?php echo wl_get_option('default_search_addr',null) ?>');
    160            
    161             getLocationsByAddress('<?php echo wl_get_option('default_search_addr',null) ?>', convertChars(tag), <?php echo wl_get_option('default_search_radius',null) ?>);
    162             jQuery("#place-selector").show();
     417    jQuery('#welocally-post-error').addClass('welocally-error error fade');
     418    jQuery('#welocally-post-error').show();
     419}
     420
     421// intercepts a next event and resets everything, but is acting as the first phase
     422function cancelHandler(event) {
     423        setStatus('','message', false);
     424       
     425        //reset selected place
     426        selectedPlace = {
     427            properties: {},
     428            type: "Place",
     429            classifiers: [
     430                {
     431                    type: '',
     432                    category: '',
     433                    subcategory: ''
     434                }
     435            ],
     436            geometry: {
     437                    type: "Point",
     438                    coordinates: []
     439            }
     440        };
     441       
     442        //wipe clean any input fields
     443        jQuery('#place-selector-form input').val('');
     444       
     445        //all sections hidden
     446        jQuery('.resetable').hide();
     447   
     448        jQuery('#edit-place-form').hide();
     449        jQuery('#place-selector').show();
     450       
     451        return nextHandler(event);
     452       
     453}
     454
     455function nextHandler(event) {
     456    console.log('next phase:'+event.data.phase);
     457    setStatus('','message', false);
     458    var phase = event.data.phase;
     459    var error = false;
     460    if(phase=='associate-place-section'){
     461        jQuery('.resetable', jQuery('#search-place-name-section')).show();
     462        jQuery('#cancel-finder-workflow').hide();
     463        var section = jQuery('#search-place-name-section');
     464        jQuery('#back-action' ).hide();
     465        section.append(jQuery('#edit-place-name-title'));
     466        section.append(jQuery('#place-name-input'));
     467        section.append(jQuery('#place-name-saved'));
     468        section.append(jQuery('#back-action'));
     469        section.append(jQuery('#next-action'));
     470        section.show();
     471       
     472        jQuery('#place-name-title').html('Search Term: Enter a search term such as the place name or the category ie. "Pizza"');       
     473       
     474        //manage event model
     475        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'search-place-name-section' }, nextHandler);       
     476        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'search-place-name-section' }, backHandler);
     477       
     478        jQuery('#place-selector-form').show();
     479       
     480                           
     481    } else if(phase=='search-place-name-section'){
     482        if (WELOCALLY.util.trim(jQuery("#edit-place-name").val()) == ''){
     483            setStatus('Search Empty. Please enter a search term or place name.','error', false);
     484            error = true;
     485
     486        } else {
     487            selectedPlace.properties.name = jQuery("#edit-place-name").val();
     488       
     489            jQuery('#edit-place-name-selected').html(selectedPlace.properties.name);
     490            jQuery('#place-street-title').html('Location: Choose the location or full address you would like to search from. ie. Oakland, CA 94612');
     491                               
     492            //put the address search in the top
     493            jQuery('.resetable', jQuery('#search-place-address-section')).show();
     494           
     495            var section = jQuery('#search-place-address-section'); 
     496            section.append(jQuery('#edit-place-name-selected'));       
     497            section.append(jQuery('#street-name-input'));
     498            section.append(jQuery('#street-address-saved'));   
     499            section.append(jQuery('#back-action'));
     500            section.append(jQuery('#next-action'));
     501           
     502            jQuery('#back-action').show();
     503           
     504            section.show();
     505           
     506            jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'search-place-address-section' }, nextHandler);     
     507            jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'search-place-address-section' }, backHandler);
    163508        }
    164     });
    165 
    166 }
    167 
    168 function convertChars(mystring){
    169     return mystring.replace(/&amp;/g, '&').replace(/&gt;/g, '>' ).replace(/&lt;/g, '<' ).replace(/&quot;/g, '\"' );
    170 }
    171 
     509                   
     510    } else if(phase=='search-place-address-section'){
     511        if (WELOCALLY.util.trim(jQuery('#edit-place-street').val()) == ''){
     512            setStatus('Location Empty. Please enter a location to start search from ie Oaklnd CA, 94612.','error', false);
     513            error = true;
     514
     515        } else {
     516           
     517            setStatus('Geocoding...','message', true);
     518       
     519            var address = jQuery('#edit-place-street').val();
     520           
     521            jQuery('#search-geocoded-section').append(jQuery('#back-action')); 
     522           
     523            jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'search-place-address-section' }, backHandler);
     524                           
     525            geocoder.geocode( { 'address': address}, function(results, status) {
     526                if (status == google.maps.GeocoderStatus.OK &&  validGeocodeForSearch(results[0])) {
     527                    jQuery('#search-geocoded-name-selected').html(selectedPlace.properties.name);
     528                    jQuery('#search-geocoded-address-selected').html(results[0].formatted_address);                                     
     529                    jQuery('#search-geocoded-section').append(jQuery('#search-geocoded-address-selected'));
     530                    jQuery('#search-geocoded-section').append(jQuery('#map_canvas'));   
     531                                           
     532                    //do the map stuff
     533                    selectedGeocode = results[0];
     534       
     535                    //set the model
     536                    selectedPlace.properties.address =
     537                        getShortNameForType("street_number", selectedGeocode.address_components)+' '+
     538                        getShortNameForType("route", selectedGeocode.address_components);
     539                   
     540                    selectedPlace.properties.city =
     541                        getShortNameForType("locality", selectedGeocode.address_components);
     542                   
     543                    selectedPlace.properties.province =
     544                        getShortNameForType("administrative_area_level_1", selectedGeocode.address_components);
     545           
     546                    selectedPlace.properties.postcode =
     547                        getShortNameForType("postal_code", selectedGeocode.address_components);
     548                   
     549                    selectedPlace.properties.country =
     550                        getShortNameForType("country", selectedGeocode.address_components);
     551                   
     552                    selectedPlace.geometry.coordinates = [];
     553                    selectedPlace.geometry.coordinates.push(selectedGeocode.geometry.location.lng());
     554                    selectedPlace.geometry.coordinates.push(selectedGeocode.geometry.location.lat());
     555   
     556           
     557                    var myOptions = {
     558                      zoom: 15,
     559                      mapTypeId: google.maps.MapTypeId.ROADMAP
     560                    };
     561                   
     562                    if(map==null){
     563                        map = new google.maps.Map(document.getElementById("map_canvas"),
     564                            myOptions);
     565                    }
     566                           
     567                    deleteOverlays();
     568                    map.setCenter(selectedGeocode.geometry.location);                               
     569                    addMarker(map,selectedGeocode.geometry.location);                   
     570                   
     571                    jQuery('.resetable', jQuery('#search-geocoded-section')).show();   
     572                    jQuery('#back-action').hide();                                         
     573                    jQuery('#search-geocoded-section').show(); 
     574                                   
     575                    setStatus('','message', false);
     576                   
     577                    //ajax call
     578                    searchLocations(selectedGeocode.geometry.location, selectedPlace.properties.name, 30);
     579                                       
     580                           
     581                } else {
     582                    console.log("Geocode was not successful for the following reason: " + status);
     583                    setStatus('There was a problem geocoding with the specified location,'+
     584                        ' please make your search more specific and try again. status:'+
     585                        status, 'update', false);                           
     586                   
     587                    jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'search-place-address-section' }, backHandler);
     588                    jQuery('#search-place-address-section').append(jQuery('#back-action'));
     589                    jQuery('#search-place-address-section').append(jQuery('#cancel-finder-workflow'));
     590                    jQuery('#search-place-address-section').show();             
     591                   
     592                }
     593            });
     594           
     595        }
     596               
     597       
     598           
     599    } else if(phase=='edit-place-name-section'){
     600           
     601           
     602        selectedPlace.properties.name = jQuery("#edit-place-name").val();
     603        jQuery('#edit-place-name-selected').html(selectedPlace.properties.name);
     604                   
     605        //put the address search in the top
     606        jQuery('#place-street-title').html('Location: Enter full street address where the place is as one line ie. 1714 Franklin Street, Oakland, CA 94612');
     607       
     608        var section = jQuery('#edit-place-address-section');
     609        section.append(jQuery('#edit-place-name-selected'));
     610        section.append(jQuery('#street-name-input'));
     611        section.append(jQuery('#street-address-saved'));           
     612        section.append(jQuery('#back-action'));
     613        section.append(jQuery('#next-action'));
     614        jQuery('#back-action').show();
     615        section.show();
     616               
     617        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'edit-place-address-section' }, nextHandler);       
     618        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-place-address-section' }, backHandler);
     619       
     620       
     621    } else if(phase=='edit-place-address-section'){
     622                   
     623        setStatus('Geocoding...','message', true);
     624        var address = jQuery('#edit-place-street').val();
     625       
     626        var section = jQuery('#edit-place-address-section');
     627        section.append(jQuery('#back-action'));         
     628        section.append(jQuery('#next-action'));
     629        jQuery('#back-action').show();     
     630        section.show();
     631       
     632        jQuery('#edit-geocoded-section').append(jQuery('#back-action'));
     633       
     634        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-geocoded-section' }, backHandler);
     635               
     636        geocoder.geocode( { 'address': address}, function(results, status) {
     637            if (status == google.maps.GeocoderStatus.OK &&  validGeocodeForSearch(results[0])) {
     638                jQuery('#edit-geocoded-name-selected').html(selectedPlace.properties.name);
     639                jQuery('#edit-geocoded-address-selected').html(results[0].formatted_address);                                       
     640               
     641                jQuery('#edit-geocoded-section').append(jQuery('#map_canvas'));
     642                                       
     643                //do the map stuff
     644                selectedGeocode = results[0];
     645   
     646                //set the model
     647                selectedPlace.properties.address =
     648                    getShortNameForType("street_number", selectedGeocode.address_components)+' '+
     649                    getShortNameForType("route", selectedGeocode.address_components);
     650               
     651                selectedPlace.properties.city =
     652                    getShortNameForType("locality", selectedGeocode.address_components);
     653               
     654                selectedPlace.properties.province =
     655                    getShortNameForType("administrative_area_level_1", selectedGeocode.address_components);
     656       
     657                selectedPlace.properties.postcode =
     658                    getShortNameForType("postal_code", selectedGeocode.address_components);
     659               
     660                selectedPlace.properties.country =
     661                    getShortNameForType("country", selectedGeocode.address_components);
     662               
     663                selectedPlace.geometry.coordinates = [];
     664                selectedPlace.geometry.coordinates.push(selectedGeocode.geometry.location.lng());
     665                selectedPlace.geometry.coordinates.push(selectedGeocode.geometry.location.lat());
     666           
     667                var myOptions = {
     668                  zoom: 15,
     669                  mapTypeId: google.maps.MapTypeId.ROADMAP
     670                };
     671               
     672                if(map==null){
     673                    map = new google.maps.Map(document.getElementById("map_canvas"),
     674                        myOptions);
     675                }
     676                       
     677                deleteOverlays();
     678                map.setCenter(selectedGeocode.geometry.location);                               
     679                addMarker(map,selectedGeocode.geometry.location);                   
     680                                                           
     681                setStatus('','message', false);     
     682                   
     683                jQuery('.resetable', jQuery('#edit-geocoded-section')).show();                 
     684                jQuery('#edit-geocoded-section').show();   
     685               
     686                getCategories(null, null);
     687                                       
     688                       
     689            } else {
     690                setStatus('There was a problem geocoding with the specified location,'+
     691                    ' please make your search more specific and try again. status:'+
     692                    status, 'update', false);
     693                jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-place-address-section' }, backHandler);           
     694                jQuery('#edit-place-address-section').append(jQuery('#back-action'));   
     695                jQuery('#edit-place-address-section').append(jQuery('#cancel-finder-workflow'));
     696                jQuery('#edit-place-address-section').show();   
     697            }
     698        });             
     699    }   
     700   
     701    if(!error){
     702        jQuery('#'+phase).hide();   
     703    }
     704   
     705    return false;
     706}
     707
     708function backHandler(event) {
     709    console.log('back phase:'+event.data.phase);
     710    setStatus('','message', false);
     711    var phase = event.data.phase;
     712    if(phase=='search-place-name-section'){         
     713        jQuery('#place-selector-form').hide();
     714        jQuery('#cancel-finder-workflow').hide();
     715        jQuery('#associate-place-section').append(jQuery('#next-action'));
     716           
     717        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'associate-place-section' }, nextHandler);
     718       
     719        jQuery('#associate-place-section').show();     
     720       
     721    } else if(phase=='search-place-address-section') { 
     722        var section = jQuery('#search-place-name-section');     
     723        section.append(jQuery('#back-action'));
     724        section.append(jQuery('#next-action'));
     725       
     726        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'search-place-name-section' }, nextHandler);
     727        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'search-place-name-section' }, backHandler);
     728       
     729        jQuery('#search-geocoded-section').hide();     
     730       
     731        section.show();     
     732           
     733    } else if(phase=='search-geocoded-section') {     
     734        jqxhr.abort();
     735        jQuery('#welocally-post-error').html('');
     736        jQuery('#search-geocoded-section').hide();
     737        jQuery('#search-place-address-section').show();
     738        jQuery("#results").show();     
     739       
     740    } else if (phase =='edit-place-address-section'){
     741        var section = jQuery('#edit-place-name-section');
     742        section.append(jQuery('#back-action'));
     743        section.append(jQuery('#next-action'));
     744        jQuery('#edit-geocoded-section').hide();
     745        jQuery('#categories-section').hide();
     746        jQuery('#edit-place-optional-section').hide();
     747               
     748        section.show();
     749       
     750        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'edit-place-name-section' }, nextHandler);
     751        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-place-name-section' }, backHandler);
     752   
     753    } else if (phase =='edit-geocoded-section' || phase=='edit-place-optional-section' ){
     754       
     755        var section = jQuery('#edit-place-address-section');
     756       
     757        section.append(jQuery('#back-action'));
     758        section.append(jQuery('#next-action'));
     759       
     760        jQuery('#edit-geocoded-section').hide();
     761        jQuery('#categories-section').hide();
     762       
     763        //reset cat selector type
     764        selectedClassifierLevel='';
     765        selectedPlace.classifiers[0].type='';
     766        selectedPlace.classifiers[0].category='';
     767        selectedPlace.classifiers[0].subcategory='';
     768       
     769        jQuery('#edit-place-categories-selected-list').html('');
     770       
     771        jQuery('#edit-place-optional-section').hide();     
     772           
     773        section.show();
     774       
     775        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'edit-place-address-section' }, nextHandler);
     776        jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-place-address-section' }, backHandler);
     777   
     778    }
     779   
     780
     781   
     782    jQuery('#'+phase).hide();   
     783    return false;
     784   
     785}
    172786
    173787jQuery(document).ready(function(jQuery) {
    174     //is this an autoload?
    175     jQuery.each(tags, function(i,tag){
    176         if(tag == 'Autoload'){
    177             jQuery("input[name='isWLPlace']").val('true');
    178             autoload(tags);         
    179         }
    180     });
    181    
    182      if (typeof(jQuery.fn.parseJSON) == "undefined" || typeof(jQuery.parseJSON) != "function") {
    183 
    184         //extensions, this is because prior to 1.4 there was no parse json function
    185         jQuery.extend({
    186             parseJSON: function( data ) {
    187                 if ( typeof data !== "string" || !data ) {
    188                     return null;
    189                 }   
    190                 data = jQuery.trim( data );   
    191                 if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
    192                     .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
    193                     .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {   
    194                     return window.JSON && window.JSON.parse ?
    195                         window.JSON.parse( data ) :
    196                         (new Function("return " + data))();   
    197                 } else {
    198                     jQuery.error( "Invalid JSON: " + data );
    199                 }
    200             }
    201         });
    202     }   
    203    
     788   
     789    WELOCALLY.env.initJQuery();
     790   
     791    //all sections hidden
     792    jQuery('.resetable').hide();
     793
     794    activityType = 'search';
     795       
     796    geocoder = new google.maps.Geocoder();
     797         
    204798    var selectedPlaceObject = null;
    205799   
    206     <?php if( $_isWLPlace == 'true') : ?>
    207     jQuery("#placeForm").show();
    208     <?php endif; ?>
    209    
    210     <?php if( $_PlaceSelected != '') : ?>
    211     selectedPlaceObject = jQuery.parseJSON( '<?php echo $bodytag = str_replace("'", "\'", $_PlaceSelected); ?>' );
    212     setSelectedPlaceInfo(selectedPlaceObject);
    213     <?php endif; ?>
    214    
    215    
    216     jQuery("#welocally_default_search_radius").val('<?php echo wl_get_option('default_search_radius',null) ?>');
    217    
    218    
    219    
    220     jQuery( "#search-places-action" ).click(function() {
    221         var missingRequired = false;
    222         var fields = '';
    223         if (!jQuery("#place-address").val().match(/\S/)) {
    224             missingRequired = true;
    225             fields = fields+'Place Address - ';
    226         }
    227         if (!jQuery("#place-search").val().match(/\S/)) {
    228             missingRequired = true;
    229             fields = fields+'Search Term - ';
    230         }
    231        
    232        
    233         if(missingRequired){
    234             buildMissingFieldsErrorMessages(fields);
    235             return false;
    236         }
    237        
    238         getLocationsByAddress(
    239             jQuery('#place-address').val(),
    240             jQuery('#place-search').val(),
    241             jQuery('#welocally_default_search_radius').val());
    242         return false;       
    243     });
    244 
    245     jQuery( "#add-place-action" ).click(function() {
    246    
    247         jQuery('#welocally-post-error').removeClass('welocally-error welocally-update error updated fade');
     800    //init buttons
     801    jQuery( 'a, input:submit, button','.action' ).button();
     802    jQuery( '#next-action,#cancel-finder-workflow,#btn-new-select,#back-action,#save-place-action' ).button();
     803   
     804    //resets all and starts over
     805    jQuery('#cancel-finder-workflow,#btn-new-select' ).bind('click' , { phase: 'associate-place-section' }, cancelHandler);
     806   
     807   
     808    jQuery('#next-action' ).bind('click' , { phase: 'associate-place-section' }, nextHandler);
     809       
     810    jQuery('#welocally_default_search_radius').val('8');
     811   
     812    //startup phase state
     813    jQuery('#associate-place-section').append(jQuery('#associate-input'));
     814    jQuery('#associate-place-section').append(jQuery('#next-action'));
     815       
     816
     817    jQuery( '#add-place-action' ).click(function() {
     818
     819        //put the fields
     820        //put the name search in the top
     821        jQuery('#edit-place-name-section').append(jQuery('#place-name-title'));
     822        jQuery('#edit-place-name-section').append(jQuery('#place-name-input'));
     823        jQuery('#edit-place-name-section').append(jQuery('#place-name-saved'));
     824        jQuery('#place-name-saved').hide();
     825        jQuery('#place-name-input').show();
     826        jQuery('#place-name-title').html('Place Name: Enter the <strong>full name</strong> of the place you want to add.');
     827       
     828        jQuery('#welocally-post-error').removeClass('welocally-error error welocally-update updated fade');
    248829        jQuery('#welocally-post-error').html('');
    249    
    250         jQuery("#place-selector").hide();
    251         jQuery("#add-place-form").show();
    252        
     830        jQuery('#results').hide();
     831        jQuery('#place-selector').hide();
     832        jQuery('#edit-place-form').show();
     833        jQuery('#map_canvas').height( 401 );
     834        jQuery('#map_canvas').width( '100%' );
     835                   
    253836        return false;
    254837    });
    255838   
    256     jQuery( "#cancel-add-link" ).click(function() {
    257         jQuery("#add-place-form").hide();
    258         if(selectedPlaceObject == null) {
    259             jQuery("#place-selector").show();
    260         } else {
    261             jQuery("#place-selector").show();
    262         }
    263         return false;
    264     });
    265 
    266    
    267     jQuery( "#btn-new-select" ).click(function() { 
    268         isSelected=false;
    269         jQuery("#selected-place").hide();
    270         jQuery("#place-selector").show();           
    271         return false;
    272     });
    273    
     839           
    274840    //saves a new place
    275     jQuery( "#save-place-action" ).click(function() {   
    276    
    277         jQuery('#welocally-post-error').removeClass('welocally-error welocally-update error updated fade');
    278         jQuery('#welocally-post-error').html('<em>Saving New Place...</em>');
     841    jQuery( '#save-place-action' ).click(function() {   
     842       
     843        setStatus('Saving Place...', 'message', true);
     844       
     845        var options = {
     846            action: 'save_place'
     847        };
    279848   
    280849        var missingRequired = false;
    281850        var fields = '';
    282         if (!jQuery("#add-place-name").val().match(/\S/)) {
    283             missingRequired = true;
    284             fields = fields+'Place Name - ';
    285         }
    286         if (!jQuery("#add-place-street").val().match(/\S/)) {
    287             missingRequired = true;
    288             fields = fields+'Street Address - ';
    289         }
    290         if (!jQuery("#add-place-city").val().match(/\S/)) {
    291              missingRequired = true;
    292             fields = fields+'City - ';
    293         }
    294         if (!jQuery("#add-place-state").val().match(/\S/)) {
    295              missingRequired = true;
    296              fields = fields+'State or Provence - ';
    297         }
    298         if (!jQuery("#add-place-zip").val().match(/\S/)) {
    299             missingRequired = true;
    300              fields = fields+'Postal Code - ';
    301         }
    302        
    303         if(missingRequired){
    304             buildMissingFieldsErrorMessages(fields);
    305             return false;
     851   
     852        if(jQuery('#edit-place-phone').val() != null){
     853            selectedPlace.properties.phone=jQuery('#edit-place-phone').val();
    306854        }
    307 
    308                
    309         var options = {
    310             action: 'add_place',
    311             siteKey : '<?php echo wl_get_option('siteKey',null) ?>',
    312             siteToken : '<?php echo wl_get_option('siteToken',null) ?>',
    313             baseurl : '<?php echo wl_get_option('siteHome',get_bloginfo('home')); ?>',
    314             placeName: jQuery('#add-place-name').val(),
    315             placeStreet: jQuery('#add-place-street').val(),
    316             placeCity: jQuery('#add-place-city').val(),
    317             placeState: jQuery('#add-place-state').val(),
    318             placeZip: jQuery('#add-place-zip').val(),
    319             placePhone: jQuery('#add-place-phone').val(),
    320             placeWeb: jQuery('#add-place-web').val(),
    321             placeCats: jQuery('#add-place-cats').val() 
    322            
    323         };
    324        
    325 
    326        
    327         jQuery.ajax({
    328           type: 'POST',
     855       
     856        if(jQuery('#edit-place-web').val() != null){
     857            selectedPlace.properties.website=jQuery('#edit-place-web').val();
     858        }
     859         
     860        //this will get changed to PUT by the ajax admin function     
     861        options.place = selectedPlace;
     862           
     863        jqxhr = jQuery.ajax({
     864          type: 'POST',       
    329865          url: ajaxurl,
    330           dataType: 'json',
    331866          data: options,
     867          dataType : 'json',
     868          beforeSend: function(jqXHR){
     869            jqxhr = jqXHR;
     870          },
    332871          error : function(jqXHR, textStatus, errorThrown) {
    333                     console.error(textStatus);
    334                     jQuery('#welocally-post-error').html('ERROR : '+textStatus);
    335                     jQuery('#welocally-post-error').addClass('welocally-error error fade');
     872            if(textStatus != 'abort'){
     873                setStatus('ERROR : '+textStatus, 'error', false);
     874            }   else {
     875                console.log(textStatus);
     876            }       
    336877          },         
    337878          success : function(data, textStatus, jqXHR) {
    338879            jQuery('#welocally-post-error').html('');
    339             if(data.errors != null) {
     880            if(data != null && data.errors != null) {
    340881                buildErrorMessages(data.errors);       
    341882            } else {
    342                 setSelectedPlaceInfo(data);
     883                selectedPlace._id=data.id;
     884                setStatus('Your new place has been added!', 'message', false);
     885                setSelectedPlaceInfo(selectedPlace, WELOCALLY.meta.post);
    343886            }
    344887          }
     
    348891        return false;
    349892    });
    350    
    351     jQuery("input[name='deletePlaceInfo']").change(function(){
    352 
    353         if(jQuery("input[name='deletePlaceInfo']").is(':checked')){
    354             var radios = jQuery('input:radio[name=isWLPlace]');
    355             jQuery(radios).filter('[value=false]').attr('checked', true);
    356             jQuery("#placeForm").hide();   
    357            
    358         }
    359     });     
    360    
    361     jQuery("input[name='isWLPlace']").change(function(){
    362         if (jQuery("input[name='isWLPlace']:checked").val() == 'true') {
    363            
    364                            
    365             jQuery("#placeForm").show();
    366            
    367             //no place has been selected yet
    368             if(selectedPlaceObject == null) {
    369                 jQuery("#place-selector").show();
    370             }
    371                
    372         } else if (jQuery("input[name='isWLPlace']:checked").val() == 'false') {
    373             jQuery("#placeForm").hide();   
    374         }
    375     });   
     893 
    376894   
    377895    jQuery( "#selectable" ).selectable({
    378896           selected: function(event, ui) {
    379                 selectedFeatureIndex = jQuery("#scroller-places li").index(ui.selected);
    380                 setSelectedPlaceInfo(jsonObjFeatures[selectedFeatureIndex]);               
     897                selectedFeatureIndex = jQuery("#scroller-places li").index(ui.selected);   
     898                setSelectedPlaceInfo(jsonObjFeatures[selectedFeatureIndex], WELOCALLY.meta.post);               
    381899           }
    382900    });
     
    384902    jQuery( "#selectable-cat" ).selectable({
    385903           selected: function(event, ui) {
    386                 if(selectedCategories.indexOf(ui.selected.innerText) == -1) {
    387                     selectedCategories = selectedCategories + ui.selected.innerText+",";
     904                if(selectedCategories.indexOf(ui.selected.innerHTML) == -1) {
     905                    selectedCategories = selectedCategories + ui.selected.innerHTML+",";
    388906                }
    389907                jQuery( "#place-categories-selected" ).val(selectedCategories);     
     
    398916    });
    399917   
    400    
    401 <?php if( $isPlaceChecked == 'true') : ?>
    402     jQuery("#placeForm").show();   
    403 <?php endif; ?>
     918    jQuery( "#edit-place-categories-selection-list" ).selectable({
     919           selected: function(event, ui) {
     920               
     921                if(selectedClassifierLevel == 'Type'){
     922                    selectedPlace.classifiers[0].type = ui.selected.innerHTML;
     923                } else if(selectedClassifierLevel == 'Category'){
     924                    selectedPlace.classifiers[0].category = ui.selected.innerHTML;
     925                } else if(selectedClassifierLevel == 'Subcategory'){
     926                    selectedPlace.classifiers[0].subcategory = ui.selected.innerHTML;
     927                }
     928               
     929                jQuery( "#edit-place-categories-selected-list")
     930                    .append(
     931                    '<li class="categories-selected-list-item">'+
     932                    selectedClassifierLevel+':'+ui.selected.innerHTML+'</li>');
     933               
     934                if(selectedPlace.classifiers[0].type != '' &&
     935                    selectedPlace.classifiers[0].category != '' &&
     936                    selectedPlace.classifiers[0].subcategory != '') {
     937                   
     938                    //finished
     939                    jQuery( '#edit-place-categories-selection').hide();
     940                    jQuery( '#save-place-action').show();
     941                    jQuery( '#edit-place-optional-section').show();
     942                    jQuery('#add-place-actions-section').append(jQuery('#back-action' ));
     943                    jQuery('#back-action' ).unbind('click').bind('click' , { phase: 'edit-place-optional-section' }, backHandler);
     944                   
     945                   
     946                   
     947                } else {
     948                    var type = null;
     949                    var category = null;
     950                    if(selectedPlace.classifiers[0].type != '')
     951                        type= selectedPlace.classifiers[0].type;
     952                    if(selectedPlace.classifiers[0].category != '')
     953                        category= selectedPlace.classifiers[0].category;   
     954                       
     955                    getCategories(type, category);
     956                }
     957               
     958           },
     959           unselected: function(event, ui) {
     960               
     961           }
     962    });
     963
     964   
     965    jQuery( '#add-new-place-action' ).click(function() {
     966       
     967        setStatus('', 'message', false);
     968       
     969        jQuery("#place-selector").hide();
     970       
     971        jQuery('#place-name-title').html('Place Name: Enter the common name of the place, ie. "Treehouse Coffee Shop"');       
     972               
     973        var section = jQuery('#edit-place-name-section');
     974        section.append(jQuery('#edit-place-name-title'));
     975        section.append(jQuery('#place-name-input'));
     976        section.append(jQuery('#place-name-saved'));
     977        section.append(jQuery('#next-action'));
     978        section.show();
     979       
     980        jQuery('#next-action' ).unbind('click').bind('click' , { phase: 'edit-place-name-section' }, nextHandler);
     981        jQuery('#back-action' ).unbind('click');
     982               
     983        jQuery("#edit-place-form").show();
     984               
     985        return false;
     986       
     987    });
     988   
     989    jQuery( "#selectable-cat" ).selectable({
     990           selected: function(event, ui) {
     991                if(selectedCategories.indexOf(ui.selected.innerHTML) == -1) {
     992                    selectedCategories = selectedCategories + ui.selected.innerHTML+",";
     993                }
     994                jQuery( "#place-categories-selected" ).val(selectedCategories);     
     995           },
     996           unselected: function(event, ui) {
     997                if(selectedCategories.indexOf(ui.unselected.innerText) != -1) {
     998                    var replaceText =  ui.unselected.innerText+",";
     999                    selectedCategories = selectedCategories.replace(new RegExp(replaceText, 'g'),"");
     1000                    jQuery( "#place-categories-selected" ).val(selectedCategories);
     1001                }       
     1002           }
     1003    });
    4041004
    4051005
    4061006});
    407 
    4081007</script>
    4091008<style type="text/css">
     
    4111010    #place-intro { margin-top: 5px; margin-bottom: 5px; }
    4121011   
    413     #placeForm {
     1012    #place-selector-form {
    4141013        border-color:#dfdfdf;
    4151014        background-color:#F9F9F9;
     
    4251024        border-spacing:0;
    4261025        padding: 10px;
    427         display:none;
     1026       
    4281027     }
     1028     
     1029    .welocally-error {
     1030        border-color:#996666;
     1031        background-color:#F9AAAA;
     1032        border-width:1px;
     1033        border-style:solid;
     1034        -moz-border-radius:3px;
     1035        -khtml-border-radius:3px;
     1036        -webkit-border-radius:3px;
     1037        border-radius:3px;
     1038        margin: 0;
     1039        width:95%;
     1040        border-style:solid;
     1041        border-spacing:0;
     1042        padding: 10px;
     1043        margin-bottom: 5px;
     1044        color:#996666;
     1045        display:none;
     1046     }
     1047     
     1048     .error-txt {
     1049        color:#850F00;
     1050        font-weight:bold;
     1051        font-size:1.0em;
     1052     }
     1053     
     1054     
     1055    .verified-geocode {
     1056        border-color:#245E07;
     1057        background-color:#B7ED9D;
     1058        border-width:2px;
     1059        border-style:solid;
     1060        -moz-border-radius:3px;
     1061        -khtml-border-radius:3px;
     1062        -webkit-border-radius:3px;
     1063        border-radius:3px;
     1064        margin: 0px;
     1065        border-style:solid;
     1066        border-spacing:0;
     1067        padding: 0px;
     1068        margin-bottom: 5px;
     1069        color:#245E07;
     1070        display:inline-block;
     1071     } 
     1072     
     1073     .error-geocode {
     1074        border-color:#8A0E0E;
     1075        background-color:#E68C8C;
     1076        border-width:2px;
     1077        border-style:solid;
     1078        -moz-border-radius:3px;
     1079        -khtml-border-radius:3px;
     1080        -webkit-border-radius:3px;
     1081        border-radius:3px;
     1082        margin: 0px;
     1083        border-style:solid;
     1084        border-spacing:0;
     1085        padding: 0px;
     1086        margin-bottom: 0px;
     1087        color:#8A0E0E;
     1088        display:inline-block;
     1089    } 
    4291090   
    4301091    #add-span { }
     
    4431104    }
    4441105   
    445     /* ------- is place */
    446     #all_place_info { width: 100%; }   
     1106    .field-title{
     1107        font-size:1.2em;
     1108        margin-top: 10px;
     1109        color: #808080;
     1110     }
    4471111   
    4481112    /* ------ selection form */
    449     #place-selector { margin-bottom: 10px; display:none; }
     1113    #place-selector { margin-bottom: 10px;}
    4501114    #scroller-places { height: 240px; width: 100%; overflow-y: scroll;}
    4511115    .search-field { width: 100%; margin-bottom: 10px; }
     
    4561120    #selectable li { margin: 3px 3px 3px 0; padding: 0.2em; cursor: pointer; } 
    4571121    #categories-choice {  margin-bottom: 10px; display:none; } 
     1122       
    4581123       
    4591124    /* ------ selected place */
     
    4691134   
    4701135    /* ------ add new place */
    471     #add-place-form { margin-bottom: 10px; width: 100%; display:none; }
     1136    #edit-place-form { margin-bottom: 10px; width: 100%; display:none; }
     1137    .edit-field { width: 100%; margin-bottom: 10px; display:inline-block; font-size:1.2em; }
     1138    .selected-field { width: 100%; height: 15px; margin-bottom: 5px; display:inline-block; font-size:1.4em; }
     1139   
     1140    .tag-field { width: 100%; height: 15px; margin-bottom: 5px;
     1141        display:inline-block;
     1142        font-weight:bold;color:#696969;
     1143        text-align:left;font-family:courier new, courier, monospace;line-height:1;
     1144        font-size:1.0em; }
     1145   
     1146    #edit-place-categories-selection-list .ui-selecting { background: #AAAAAA; color: black; }
     1147    #edit-place-categories-selection-list .ui-selected {
     1148        background: #7A5207; color: white;
     1149    }
     1150    #edit-place-categories-selection-list { list-style-type: none; margin: 0; padding: 0; }
     1151    #edit-place-categories-selection-list li {
     1152        margin: 3px 3px 3px 0; padding: 0.2em; cursor: pointer;
     1153        border-color:#4E8727;
     1154        background-color:#C4F2A5;
     1155        border-width:1px;
     1156        border-style:solid;
     1157        -moz-border-radius:3px;
     1158        -khtml-border-radius:3px;
     1159        -webkit-border-radius:3px;
     1160        border-radius:3px;
     1161        border-style:solid;
     1162        border-spacing:0;
     1163        color:#4E8727;
     1164        display:inline-block;
     1165    }   
     1166   
     1167    .categories-selected-list-item {
     1168        border-color:#737373;
     1169        background-color:#505050;
     1170        border-width:0px;
     1171        border-style:solid;
     1172        -moz-border-radius:3px;
     1173        -khtml-border-radius:3px;
     1174        -webkit-border-radius:3px;
     1175        border-radius:3px;
     1176        margin: 0px;
     1177        border-style:solid;
     1178        border-spacing:0;
     1179        font-size:1.2em;
     1180        padding: 5px;
     1181        margin-right: 5px;
     1182        color:#FFFFFF;
     1183        display:inline-block;
     1184     }
    4721185       
    4731186</style>
    474 <div id="place-intro">
    475 <div id="welocally-post-error"></div>
    476 <?php
    477 if(is_subscribed()):
    478 
    479 try {
    480     do_action('sp_places_post_errors', $postId );
    481     if( !$this->postExceptionThrown ) delete_post_meta( $postId, self::WLERROROPT );
    482 } catch ( WLPLACES_Post_Exception $e) {
    483     $this->postExceptionThrown = true;
    484     update_post_meta( $postId, self::WLERROROPT, trim( $e->getMessage() ) );
    485     $e->displayMessage( $postId );
    486 }
    487 
    488 
    489 ?>
    490     <div>
    491     <?php _e('Delete place info for this post?',$this->pluginDomain); ?>&nbsp;
    492     <label><input type='radio' name='deletePlaceInfo' value='true' />&nbsp;<b><?php _e('Yes', $this->pluginDomain); ?></b></label>
    493     </div>
    494     <div>
    495     <?php _e('Associate a place with this post?',$this->pluginDomain); ?>&nbsp;
    496     <label><input type='radio' name='isWLPlace' value='true' <?php echo $isPlaceChecked; ?> />&nbsp;<b><?php _e('Yes', $this->pluginDomain); ?></b></label>
    497     <label><input type='radio' name='isWLPlace' value='false' <?php echo $isNotPlaceChecked; ?> />&nbsp;<b><?php _e('No', $this->pluginDomain); ?></b></label>
    498     </div>
    499 </div>
    500 <div id="placeForm">
    501     <input type="hidden" id="place-selected" name="PlaceSelected">
    502     <input type="hidden" id="place-categories-selected" name="PlaceCategoriesSelected">
    503     <div id="all_place_info">
    504         <!-- start place selector -->
    505         <div id="place-selector">
    506             <div class="meta-title2">Select Place</div>
    507             <div>   
    508                 <div>*<em>Please enter the closest address, this can just be the city and state (ie. Oakland, CA), or the full address...</em> REQUIRED</div>
    509                 <div style="margin-bottom:5px">
    510                     <input type="text" id="place-address"
    511                         class="search-field"
    512                         value="<?php echo wl_get_option('default_search_addr',null) ?>">
    513                     <select id="welocally_default_search_radius" name="welocally_default_search_radius" >
    514                         <option value="2">2 km</option>
    515                         <option value="4">4 km</option>
    516                         <option value="8">8 km</option>
    517                         <option value="12">12 km</option>
    518                         <option value="16">16 km</option>
    519                         <option value="25">25 km</option>
    520                         <option value="50">50 km</option>
    521                     </select>&nbsp;<em>Distance in Km</em> 
    522                        
    523                 </div> 
    524                 <div>*<em>What is the name of the place you are writing about or a simillar keyword...</em> REQUIRED</div>
    525                 <div><input type="text" id="place-search" class="search-field"></div>
    526                 <div>
    527                     <button id="search-places-action">find places</button>
    528                     <span id="add-span">don't see a match?&nbsp;&nbsp;<button id="add-place-action">add new place</button></span>
    529                 </div>
    530             </div>
    531             <div id="results">
     1187<body>
     1188    <div style="display:none">
     1189       
     1190        <div id="associate-input" class="action" style="display:inline-block" >
     1191            <div style="display:inline-block" class="selected-field">Associate a place with this post?&nbsp;</div>         
     1192        </div>
     1193   
     1194        <div id="place-name-input" class="action" style="display:inline-block">
     1195            <div id="place-name-title"  class="field-title">*Place Name: <em>Required</em></div>
     1196            <input type="text" id="edit-place-name" name="edit-place-name" class="edit-field">
     1197            <button id="save-place-name-action" href="#" style="display:none">Save</button>
     1198        </div>                         
     1199
     1200        <div id="street-name-input" class="action" style="display:inline-block">           
     1201            <div id="place-street-title"  class="field-title">*Full Address: <em>Required</em></div>
     1202            <input type="text" id="edit-place-street" name="edit-place-street" class="edit-field">
     1203        </div>
     1204       
     1205
     1206        <div class="resetable" id="map_canvas" style="width:100%; height:300px;"></div>
     1207        <div class="resetable" id="results">
    5321208                <div id="scroller-places">
    5331209                    <ol id="selectable">
    5341210                    </ol>   
    5351211                </div>
    536             </div>     
    537         </div>
    538         <!-- end place selector -->
    539         <!-- start place selector -->
    540         <div id="selected-place">
    541             <div class="meta-title2">Selected Place</div>
    542             <div id="selected-place-info"></div>
    543             <div id="categories-choice">
    544                 <strong><?php _e('Choose categories for post:',$this->pluginDomain); ?></strong>&nbsp;
    545                 <ol id="selectable-cat"></ol>
    546             </div>
    547             <button id="btn-new-select" href="#">new selection</button>
    548         </div>
    549         <!-- end place selector -->
    550         <!-- add place form -->
    551         <div id="add-place-form">           
    552             <div class="meta-title2">Add New Place</div>
    553             Place Name: <em>Required</em></br>
    554             <input type="text" id="add-place-name" name="add-place-name" class="search-field"></br>
    555             Street Address: <em>Required</em></br>
    556             <input type="text" id="add-place-street" name="add-place-street" class="search-field"></br>
    557             City: <em>Required</em></br>
    558             <input type="text" id="add-place-city" name="add-place-city" class="search-field"></br>
    559             State or Provence: <em>Required</em></br>
    560             <input type="text" id="add-place-state" name="add-place-state" class="search-field"></br>
    561             Zip or Postal Code: <em>Required</em></br>
    562             <input type="text" id="add-place-zip" name="add-place-zip" class="search-field"></br>
    563             Phone Number: (optional):</br>
    564             <input type="text" id="add-place-phone" name="add-place-phone" class="search-field"></br>
    565             Website: (optional):</br>
    566             <input type="text" id="add-place-web" name="add-place-web" class="search-field"></br>
    567             Categories (comma seperated):</br>
    568             <input type="text" id="add-place-cats" name="add-place-cats" class="search-field"></br>         
    569             <button id="cancel-add-link" href="#">Cancel</button>
    570             <button id="save-place-action" href="#">Add Place</button>
    571         </div>
    572         <!-- end add place form -->
    573 
    574     </div>
    575    
    576 <?php else:
    577     echo '<div class="error fade"><p><strong>' . __( 'Please Subscribe To Activate Welocally Places' ) . "</strong></p></div>\n";
    578 endif;?>     
    579 </div>
     1212                <div id="add-place-section" class="resetable action" style="margin-top:10px;" >
     1213                    <div class="selected-field"><em>Can't find the place you are looking for?</em></div>
     1214                    <button id="add-new-place-action" href="#">Add Place</button>
     1215                </div>
     1216        </div> 
     1217   
     1218        <button id="next-action" href="#">Next</button>
     1219        <button id="back-action" href="#">Back</button>
     1220    </div>
     1221    <div class="container">
     1222        <div class="span-24">   
     1223            <div id="welocally-post-error" style="display:none">No Errors...</div>             
     1224                <div>                   
     1225                    <div id="associate-place-section"></div>
     1226                </div>
     1227                <input type="hidden" id="place-selected" name="PlaceSelected">
     1228                <input type="hidden" id="place-categories-selected" name="PlaceCategoriesSelected">
     1229                       
     1230                <div id="place-selector-form" style="display:none">
     1231                 <div id="all_place_info">
     1232                    <!-- start place selector -->
     1233                    <div id="place-selector">
     1234                        <div class="meta-title2">Search Places</div>
     1235                       
     1236                            <div class="resetable" id="search-place-name-section"></div>
     1237                           
     1238                            <div class="resetable" id="search-place-address-section">
     1239                                <div id="edit-place-name-selected" class="selected-field">&nbsp;</div>
     1240                            </div>
     1241                           
     1242                            <div class="resetable" id="search-geocoded-section">
     1243                                <div id="search-geocoded-name-selected" class="selected-field">&nbsp;</div>
     1244                                <div id="search-geocoded-address-selected" class="selected-field">&nbsp;</div>
     1245                                <div id="places-tag-selected" style="display:none; margin-bottom:10px;">
     1246                                    <div class="tag-line">
     1247                                        <div><em>Place this tag in your edit area to link to post. Or use the Welocally TinyMCE button to insert.</em></div>               
     1248                                        <div><input class="search-field post-place-tag-tagtext" type="text" id="share-meta-tagtext"></input></div>
     1249                                    </div>                     
     1250                                </div>
     1251                            </div>
     1252                                                                               
     1253                            <div class="resetable" id="place-find-range-section" style="display:none">
     1254                                <select id="welocally_default_search_radius" name="welocally_default_search_radius" >
     1255                                    <option value="2">2 km</option>
     1256                                    <option value="4">4 km</option>
     1257                                    <option value="8">8 km</option>
     1258                                    <option value="12">12 km</option>
     1259                                    <option value="16">16 km</option>
     1260                                    <option value="25">25 km</option>
     1261                                    <option value="50">50 km</option>
     1262                                </select>&nbsp;<em>Distance in Km</em>                                     
     1263                            </div> 
     1264                                                       
     1265                            <div class="resetable" id="place-find-query-section" style="display:none">                     
     1266                                <div>*<em>What is the name of the place you are writing about or a simillar keyword...</em> REQUIRED</div>
     1267                                <div><input type="text" id="place-search" class="class="search-field"" value="foo"></div>
     1268                            </div>
     1269                                                       
     1270                            <div class="resetable" id="place-find-actions" class="action" style="display:none">
     1271                                <button id="search-places-action">Find Places</button>                                       
     1272                            </div>                                             
     1273                        </div>
     1274                           
     1275                    </div>
     1276                    <!-- end place selector -->
     1277                    <!-- start place selector -->
     1278                    <div id="selected-place" class="resetable">
     1279                        <div class="meta-title2">Selected Place</div>
     1280                        <div id="selected-place-info"></div>
     1281                        <div id="categories-choice">
     1282                            <div class="meta-title2">Choose categories for post</div>
     1283                            <ol id="selectable-cat"></ol>
     1284                        </div>
     1285                        <div class="action"><button id="btn-new-select" href="#">New Selection</button></div>
     1286                    </div>         
     1287                    <!-- end place selector -->
     1288                   
     1289                    <!-- add place form -->
     1290                    <div id="edit-place-form">
     1291                        <div id="place-form-title" class="meta-title2">Add New Place</div>
     1292                                                                               
     1293                        <div class="resetable" id="edit-place-name-section"></div>
     1294                       
     1295                        <div class="resetable" id="edit-place-address-section" style="display:none"></div>
     1296                       
     1297                        <div class="resetable" id="edit-geocoded-section">
     1298                                <div id="edit-geocoded-name-selected" class="selected-field">&nbsp;</div>
     1299                                <div id="edit-geocoded-address-selected" class="selected-field">&nbsp;</div>
     1300                        </div>
     1301                       
     1302                        <div class="resetable" id="categories-section" style="display:none">
     1303                            <div style="margin-top:10px; height:20px;" class="field-title">*Category Info: <em>Required</em></div>
     1304                            <div id="edit-place-categories-selected"><ul id="edit-place-categories-selected-list"></ul></div>
     1305                            <div id="edit-place-categories-selection"><ul id="edit-place-categories-selection-list" style="display:inline-block; list-style:none;"></ul></div>
     1306                        </div>
     1307
     1308                        <div class="resetable" id="edit-place-optional-section" style="display:none">
     1309                            <div style="margin-top:10px; margin-bottom:5px;"><em>These fields are optional but it is strongly reccomended that you include the phone number and website.</em></div>
     1310                            <div id="step-phone">
     1311                                Phone Number: (optional):</br>
     1312                                <input type="text" id="edit-place-phone" name="edit-place-phone" class="edit-field">
     1313                            </div>
     1314                            <div id="step-web">
     1315                                Website: (optional):</br>
     1316                                <input type="text" id="edit-place-web" name="edit-place-web" class="edit-field">
     1317                            </div>
     1318                        </div>
     1319                       
     1320                        <div class="resetable" id="add-place-actions-section" class="action" style="display:inline-block; margin-top:10px;">
     1321                            <button id="cancel-finder-workflow" href="#">Cancel</button>
     1322                            <button id="save-place-action" href="#" style="display:none">Save</button>
     1323                        </div>     
     1324                    </div>
     1325                    <!-- end add place form --> 
     1326                   
     1327                </div>   <!-- end add place form -->
     1328                       
     1329
     1330        </div>
     1331    </div>
  • welocally-places/trunk/views/themes/chateau/welocally-places-list-widget-display.php

    r466267 r514360  
    33$index = 0;
    44echo '<li class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div><ul class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     5
     6foreach ($posts as $post):
     7    foreach (get_post_places($post) as $place):   
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    1518if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :
     
    2023
    2124<aside>
    22 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    23 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     25<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     26<div id="plugin-place<?php echo $index; ?>"></div>
    2427</aside>
    2528<?php endif; ?>
    2629<?php
    2730    $index=$index+1;
    28 }
     31    endforeach;
     32endforeach;
    2933echo "</ul></div></li>";
    3034?> 
  • welocally-places/trunk/views/themes/chateau/welocally-places-map-widget-display.php

    r473697 r514360  
    3030        </div>             
    3131    </div>
    32     <div class="wl-place-widget-website text-align-right">
     32    <?php /*<div class="wl-place-widget-website text-align-right">
    3333        <a href="<?php echo places_get_mapview_link(); ?>">
    3434            <?php _e('view larger', $wlPlaces->pluginDomain)?>
    3535        </a>
    36     </div>
     36    </div>*/ ?>
    3737</div>
    3838</li>
  • welocally-places/trunk/views/themes/default/category-places-map.php

    r473697 r514360  
    2929$infobox_include = WP_PLUGIN_DIR . '/' .$wlPlaces->pluginDir . '/views/includes/infobox-map-include.php';
    3030include($infobox_include);
    31 
    32 
    3331?>
    3432
  • welocally-places/trunk/views/themes/default/welocally-places-list-widget-display.php

    r463355 r514360  
    22global $wlPlaces;
    33$index = 0;
    4 echo '<li class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div><ul class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     4echo '<aside class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div><ul class="wl-places-list">';
     5
     6foreach ($posts as $post):
     7    foreach (get_post_places($post) as $place):
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    15 if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :
     18
     19//inefficient
     20if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post' && $index<$instance['limit'] ) :
    1621
    1722$places_list_include = WP_PLUGIN_DIR . '/' .$wlPlaces->pluginDir . '/views/includes/places-list-include.php';
     
    2025
    2126<aside>
    22 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    23 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     27<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     28<div id="plugin-place<?php echo $index; ?>"></div>
    2429</aside>
    2530<?php endif; ?>
    2631<?php
    2732    $index=$index+1;
    28 }
    29 echo "</ul></div></li>";
     33    endforeach;
     34endforeach;
     35echo "</ul></div></aside>";
    3036?> 
  • welocally-places/trunk/views/themes/default/welocally-places-map-widget-display.php

    r473697 r514360  
    1818
    1919
    20 <li class="widget sidebar-item">
     20<aside class="widget sidebar-item">
    2121<h3 class="widget-title"><?php echo $title; ?></h3>
    2222<div id="map_widget_container">
     
    2929        </div>             
    3030    </div>
    31             <div class="wl-place-widget-website text-align-right">
    32             <a href="<?php echo places_get_mapview_link(); ?>">
    33                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    34             </a>
    35             </div>
     31
    3632</div>
    37 </li>
     33</aside>
    3834
  • welocally-places/trunk/views/themes/lightword/welocally-places-list-widget-display.php

    r463355 r514360  
    33$index = 0;
    44echo '<li class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div><ul class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     5
     6foreach ($posts as $post):
     7    foreach (get_post_places($post) as $place):
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    1518if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') : 
     
    1922
    2023<aside>
    21 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    22 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     24<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     25<div id="plugin-place<?php echo $index; ?>"></div>
    2326</aside>
    2427<?php endif; ?>
    2528<?php
    2629    $index=$index+1;
    27 }
     30    endforeach;
     31endforeach;
    2832echo "</ul></div></li>";
    2933?> 
  • welocally-places/trunk/views/themes/lightword/welocally-places-map-widget-display.php

    r473697 r514360  
    2828        </div>             
    2929    </div>
    30             <div class="wl-place-widget-website text-align-right">
    31             <a href="<?php echo places_get_mapview_link(); ?>">
    32                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    33             </a>
    34             </div>
     30
    3531</div>
    3632</li>
  • welocally-places/trunk/views/themes/sight/welocally-places-list-widget-display.php

    r473697 r514360  
    33$index = 0;
    44echo '<aside class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     5
     6foreach ($posts as $post):
     7    foreach (get_post_places($post) as $place):
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    1518if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :   
     
    1821include($places_list_include);?>
    1922
    20 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    21 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     23<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     24<div id="plugin-place<?php echo $index; ?>"></div>
    2225<?php endif; ?>
    2326<?php
    2427    $index=$index+1;
    25 }
     28    endforeach;
     29endforeach;
    2630echo "</div></aside>";
    2731?> 
  • welocally-places/trunk/views/themes/sight/welocally-places-map-widget-display.php

    r473697 r514360  
    2626        </div>             
    2727    </div>
    28             <div class="wl-place-widget-website text-align-right">
    29             <a href="<?php echo places_get_mapview_link(); ?>">
    30                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    31             </a>
    32             </div>
     28
    3329</div>
    3430</aside>
  • welocally-places/trunk/views/themes/suffusion/welocally-places-list-widget-display.php

    r466267 r514360  
    77<div>
    88<h3 style="margin-left:5px;"><?php echo $title; ?></h3>
    9 <?php foreach( $posts as $post ) { ?>
     9<?php
     10foreach ($posts as $post):
     11    foreach (get_post_places($post) as $place):
     12?>
    1013
    1114<?php /**
     
    1518 * @return string
    1619 */
    17 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     20$PlaceSelected  = $place;
    1821
    1922if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :
     
    2427
    2528<div style="margin-left:5px; margin-right:5px;">
    26 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    27 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     29<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     30<div id="plugin-place<?php echo $index; ?>"></div>
    2831</div>
    2932<?php endif; ?>
    3033<?php
    3134    $index=$index+1;
    32 }
     35    endforeach;
     36endforeach;
    3337?>
    3438</div>
  • welocally-places/trunk/views/themes/suffusion/welocally-places-map-widget-display.php

    r473697 r514360  
    3030        </div>             
    3131    </div>
    32     <div class="wl-place-widget-website text-align-right">
    33             <a href="<?php echo places_get_mapview_link(); ?>">
    34                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    35             </a>
    36     </div>
    3732</div>
    3833</div>
  • welocally-places/trunk/views/themes/twentyeleven/category-places-map.php

    r473697 r514360  
    1919?>
    2020<?php get_header(); ?>
    21 <!-- include -->
     21<!-- include for me2 -->
    2222<?php
    2323
  • welocally-places/trunk/views/themes/twentyeleven/welocally-places-list-widget-display.php

    r463355 r514360  
    33$index = 0;
    44echo '<aside class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div><ul class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     5foreach ($posts as $post):
     6    $places = get_post_places($post->ID);
     7    foreach ($places  as $place):
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    1518if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :
     
    2124
    2225<aside>
    23 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    24 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     26<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     27<div id="plugin-place<?php echo $index; ?>"></div>
    2528</aside>
    2629<?php endif; ?>
    2730<?php
    2831    $index=$index+1;
    29 }
     32    endforeach;
     33endforeach;
     34
    3035echo "</ul></div></aside>";
    3136?> 
  • welocally-places/trunk/views/themes/twentyeleven/welocally-places-map-widget-display.php

    r473697 r514360  
    2626        </div>             
    2727    </div>
    28             <div class="wl-place-widget-website text-align-right">
    29             <a href="<?php echo places_get_mapview_link(); ?>">
    30                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    31             </a>
    32             </div>
     28
    3329</div>
    3430</aside>
  • welocally-places/trunk/views/themes/twentyten/welocally-places-list-widget-display.php

    r463355 r514360  
    33$index = 0;
    44echo '<aside class="widget sidebar-item"><h3 class="widget-title">'.$title.'</h3><div class="wl-places-list">';
    5 foreach( $posts as $post ) { ?>
     5
     6foreach ($posts as $post):
     7    foreach (get_post_places($post) as $place):
     8?>
    69
    710<?php /**
     
    1114 * @return string
    1215 */
    13 $PlaceSelected  = get_post_meta( $post->ID, '_PlaceSelected', true );
     16$PlaceSelected  = $place;
    1417
    1518if( $PlaceSelected != '' && $_REQUEST['json'] != 'get_post') :   
     
    1821include($places_list_include);?>
    1922
    20 <div class="wl-place-widget-category" id="plugin-place-category<?php echo $post->ID; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
    21 <div id="plugin-place<?php echo $post->ID; ?>"></div>
     23<div class="wl-place-widget-category" id="plugin-place-category<?php echo $index; ?>" style="{display:none;}"><?php echo $this->get_categories($post->ID, $exclude_cats); ?></div>
     24<div id="plugin-place<?php echo $index; ?>"></div>
    2225<?php endif; ?>
    2326<?php
    2427    $index=$index+1;
    25 }
     28    endforeach;
     29endforeach;
    2630echo "</div></aside>";
    2731?> 
  • welocally-places/trunk/views/themes/twentyten/welocally-places-map-widget-display.php

    r473697 r514360  
    2727        </div>             
    2828    </div>
    29             <div class="wl-place-widget-website text-align-right">
    30             <a href="<?php echo places_get_mapview_link(); ?>">
    31                 <?php _e('view larger', $wlPlaces->pluginDomain)?>
    32             </a>
    33             </div>
     29
    3430</div>
    3531</aside>
  • welocally-places/trunk/views/welocally-places-list-widget-admin.php

    r463355 r514360  
    1 <script type="text/javascript">
    2 jQuery(document).ready(function() {
    3 
    4 });
    5 </script>
    61<style type="text/css">
    72
     
    4641    <select id="<?php echo $this->get_field_id( 'order_dir' ); ?>" 
    4742        name="<?php echo $this->get_field_name( 'order_dir' ); ?>">
     43        <option value="desc" <?php if($instance['order_dir']=='desc') echo 'selected';?>>Decending</option>
    4844        <option value="asc" <?php if($instance['order_dir']=='asc') echo 'selected';?>>Acending</option>
    49         <option value="desc" <?php if($instance['order_dir']=='desc') echo 'selected';?>>Decending</option>
    5045    </select>
    5146    </div>
  • welocally-places/trunk/welocally-places-list-widget.class.php

    r463355 r514360  
    2323       
    2424            function widget( $args, $instance ) {
    25                 global $wp_query;
     25                global $wp_query,$wlPlaces;
     26                $options = $wlPlaces->getOptions();
    2627                extract( $args );
    27 
    2828                /* User-selected settings. */
    2929                $style = $instance['style'];
    3030                $title = apply_filters('widget_title', $instance['title'] );
    31                 $limit = $instance['limit'];
     31               
     32                $limit = 1000;
     33                $limit_places = $instance['limit'];
    3234                $order_by = $instance['order_by'];
    3335                $order_dir = $instance['order_dir'];
     
    4345                    /* Display list of places. */
    4446                        if( function_exists( 'get_places' ) ) {
    45                             $templateOverride = locate_template( array( 'places/places-map-widget-display.php' ) );
    46                            
    47                             $theme_dir = get_theme_view_dir(); 
    48                            
    49                             $templateLoc = $templateOverride ? $templateOverride : dirname( __FILE__ ) .
    50                                 '/views/themes/'.$theme_dir.'/welocally-places-list-widget-display.php';
    51 
     47                            $templateLoc = apply_filters('list_widget_template','');
    5248                            //view
    5349                            include( $templateLoc );
  • welocally-places/trunk/welocally-places-map-widget.class.php

    r463355 r514360  
    2626       
    2727            function widget( $args, $instance ) {
    28                 global $wp_query;
     28                global $wp_query,$wlPlaces;
     29                $options = $wlPlaces->getOptions();
    2930                extract( $args );
    3031
     
    4344                    /* Display list of places. */
    4445                        if( function_exists( 'get_places' ) ) {
    45                             $templateOverride = locate_template( array( 'places/places-map-widget-display.php' ) );
    46                            
    47                             $theme_dir = get_theme_view_dir(); 
    48                            
    49                             $templateLoc = $templateOverride ? $templateOverride : dirname( __FILE__ ) .
    50                                 '/views/themes/'.$theme_dir.'/welocally-places-map-widget-display.php';
    51 
     46                            $templateLoc = apply_filters('map_widget_template','');
    5247                            //view
    5348                            include( $templateLoc );
  • welocally-places/trunk/welocally-places.class.php

    r476641 r514360  
    11<?php
     2require_once('welocally-places-tag.class.php');
     3require_once('welocally-places-tag-processor.class.php');
     4
    25if ( !class_exists( 'WelocallyPlaces' ) ) {
    36    /**
    4      * Main plugin
    57     */
    68    class WelocallyPlaces {
    79       
    8         const VERSION               = '1.0.15';
     10        const VERSION               = '1.1.16';
     11        const DB_VERSION            = '2.0';
    912        const WLERROROPT            = '_welocally_errors';
    1013        const CATEGORYNAME          = 'Place';
     
    1417        const TIMEFORMAT            = 'g:i A';
    1518        const DBDATEFORMAT          = 'Y-m-d';
    16         const DBDATETIMEFORMAT      = 'Y-m-d G:i:s';
     19        const DBDATETIMEFORMAT      = 'Y-m-d G:i:s'; 
    1720       
    1821        public $displaying;
     
    6164            add_action( 'init',             array( $this, 'loadDomainStylesScripts' ) );
    6265            add_action( 'pre_get_posts',    array( $this, 'setOptions' ) );
    63            
     66            add_action( 'admin_enqueue_scripts',        array( $this, 'loadAdminDomainStylesScripts' ) );
    6467            add_action( 'admin_menu',       array( $this, 'addPlaceBox' ) );
    6568            add_action( 'save_post',        array( $this, 'addPlaceMetaSave' ), 15 );
     69            add_action( 'save_post',        array( $this, 'tagHandling'));
    6670            add_action( 'publish_post',     array( $this, 'addPlaceMetaPublish' ), 15 );
    6771            add_action( 'template_redirect',array($this, 'templateChooser' ), 1 );
     
    6973            add_action( 'sp_places_post_errors', array( 'WLPLACES_Post_Exception', 'displayMessage' ) );
    7074            add_action( 'sp_places_options_top', array( 'WLPLACES_Options_Exception', 'displayMessage') );
    71            
    72             add_filter( 'the_content', array($this, 'wl_content_search' ));
    73            
    74         }
    75        
    76        
    77         function wl_content_search( $content ) {
    78             $content = str_replace( '[welocally/]', $this->addPostPlaceInfoMarkup( $GLOBALS['post']->ID ), $content );
    79             return $content;
    80         }
    81        
    82        
    83 
     75
     76            add_filter( 'the_content', array( $this, 'wl_content_tag_search') );
     77        }
     78
     79        public function wl_content_tag_search($content) {
     80            return WelocallyPlaces_Tag::searchAndReplace($content, array($this, 'addPostPlaceTagMarkup'));
     81        }
     82       
     83        //this is a little strange is ths obsolete?
    8484        public function templateChooser() {
     85           
     86            //temporary disable
     87            //return;
    8588
    8689            $cat_map_layout_type = $this->getSingleOption('cat_map_layout');
     
    9396            $cat_ID = get_query_var( 'cat' );
    9497           
    95             $places_in_category_posts = get_places_posts_for_category($cat_ID);         
    96            
    97             error_log("got place count:".count($places_in_category_posts), 0);
     98            $places_in_category_posts = get_places_posts_for_category($cat_ID);                     
    9899           
    99100            if(count($places_in_category_posts) == 0)
    100101                return;
    101    
    102            
    103                    
    104             global $wp_query;
     102                                   
     103            global $wp_query, $wlPlaces;
     104            $options = $wlPlaces->getOptions();
    105105            if ( $this->in_category()) {
    106106               
    107                 if( '' == locate_template( array( 'places/category-places-map.php' ), true ) ) {
    108                                    
    109                     $theme_dir = get_theme_view_dir(); 
    110                                    
    111                     load_template( dirname( __FILE__ ) . '/views/themes/'.$theme_dir.'/category-places-map.php' );
     107                if( '' == locate_template( array( 'places/category-places-map.php' ), true ) ) {
     108                    $templateLoc = apply_filters('category_template','');
     109                        //view
     110                    load_template( $templateLoc );                 
    112111                }
    113112                exit;   
     
    116115            }
    117116        }
    118        
    119117       
    120118       
     
    154152
    155153       
    156         //----------       
     154
    157155        public function loadDomainStylesScripts() {
    158156       
     
    160158            $placesURL = trailingslashit( WP_PLUGIN_URL ) . trailingslashit( plugin_basename( dirname( __FILE__ ) ) ) . 'resources/';
    161159           
    162             //app stuff
    163             wp_enqueue_script('google-maps' , 'https://maps.google.com/maps/api/js?sensor=true' , false , '3');
     160            //app stuff, for right now we will embed this key but this should be coming from a web service
     161            wp_enqueue_script('google-maps' , 'https://maps.google.com/maps/api/js?key=AIzaSyACXX0_pKBA6L0Z2ajyIvh5Bi8h9crGVlg&sensor=true&language=en' , false , '3');
    164162            wp_enqueue_script('sp-places-script', $placesURL.'places.js', array('jquery') );
    165163            if( locate_template( array('places/places.css') ) ) {
     
    185183            wp_enqueue_script('media-upload');
    186184            wp_enqueue_script('thickbox');
    187             /*wp_register_script('wl-upload', WP_PLUGIN_URL.'/welocally-places/resources/upload.js', array('jquery','media-upload','thickbox'));
    188             wp_enqueue_script('wl-upload');*/
    189            
    190185            //color picker
    191186            wp_enqueue_script('js-color-picker',WP_PLUGIN_URL.'/welocally-places/resources/jscolor.js', array('jquery'));
    192187           
     188            wp_enqueue_script('wlplaces', WP_PLUGIN_URL . '/welocally-places/resources/wlplaces.js', array('jquery'));
     189        }
     190       
     191
     192        public function loadAdminDomainStylesScripts() {
     193                   
     194            $placesURL = trailingslashit( WP_PLUGIN_URL )
     195                . trailingslashit( plugin_basename( dirname( __FILE__ ) ) ) . 'resources/';
     196           
     197            //app stuff
     198            wp_enqueue_script('jquery-ui-all' , 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js');
     199            wp_enqueue_script('js-color-picker',WP_PLUGIN_URL.'/welocally-places/resources/jscolor.js', array('jquery'));                                   
     200            wp_enqueue_script('media-upload');
     201                   
     202            wp_enqueue_style('thickbox');
     203           
     204            wp_register_style( 'jquery-ui-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css' );
     205            wp_enqueue_style( 'jquery-ui-style' );     
    193206        }
    194207       
     
    225238        }
    226239       
    227                 /**
     240        /**
    228241         * Creates the category and sets up the theme resource folder with sample config files. Calls updateMapPostMeta().
    229242         *
     
    231244         */
    232245        public function on_activate( ) {
     246            global $wpdb;
     247           
    233248            $now = time();
    234249            $firstTime = $now - ($now % 66400);
    235             $this->create_category_if_not_exists( );   
    236         }
     250            $this->create_category_if_not_exists( );
     251           
     252            // create places table
     253            $db_version = get_option('Welocally_DBVersion');
     254           
     255            if ($db_version != self::DB_VERSION) {
     256                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     257               
     258                $sql = "CREATE TABLE {$wpdb->prefix}wl_places (
     259                    id INT PRIMARY KEY AUTO_INCREMENT,
     260                    wl_id VARCHAR(255) NOT NULL,
     261                    place TEXT NULL,
     262                    created DATETIME NOT NULL
     263                );";
     264                dbDelta($sql);
     265
     266                $sql = "CREATE TABLE {$wpdb->prefix}wl_places_posts (
     267                    id INT PRIMARY KEY AUTO_INCREMENT,
     268                    place_id INT NOT NULL,
     269                    post_id MEDIUMINT(9) NOT NULL,
     270                    created DATETIME NOT NULL
     271                );";
     272                dbDelta($sql);
     273            }
     274           
     275            update_option('Welocally_DBVersion', self::DB_VERSION);
     276        }
     277
    237278
    238279        /**
     
    252293         */
    253294        public function addPlaceBox( ) {
    254                 add_meta_box( 'Place Details', __( 'Welocally Places', 'Place_textdomain' ),
    255                         array( $this, 'placeMetaBox' ), 'post', 'normal', 'high' );
    256         }
     295            foreach (array('post','page') as $type)
     296            {
     297                add_meta_box( 'wl-place-finder-meta-1', __( 'Welocally Places', 'Place_textdomain' ),
     298                                array( $this, 'placeMetaBox' ), $type, 'normal', 'high' );
     299            }
     300        }
    257301       
    258302        public function placeMetaBox() {
     
    279323            include( dirname( __FILE__ ) . '/views/places-meta-box.php' );
    280324        }
    281        
    282        
    283 
    284 
    285    
     325
     326        public function addPostPlaceTagMarkup($tag, $str) {
     327            global $post;
     328            global $wpdb;
     329            static $placecount = 0;
     330           
     331            if (!$tag->id)
     332                return $str;
     333
     334            if ($place = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $tag->id))) {
     335                $place_json = $place->place;
     336               
     337                $resultContent = '';
     338               
     339                $showmap=true;
     340                $cat_ID = get_query_var( 'cat' );
     341               
     342                // if(is_single()){
     343                if(is_singular()){
     344                 $showmap=true;
     345                } else if(is_home() || isset($cat_ID)){
     346                 $showmap=false;
     347                }
     348               
     349                $isCustom = false;
     350                $customMapJson = '[  ]';
     351                if(wl_get_option('map_custom_style') != ''){
     352                 $isCustom = true;
     353                 $customMapJson = wl_get_option("map_custom_style");
     354                }
     355               
     356                $whereImage=$this->pluginUrl.'/resources/images/here.png';
     357               
     358
     359                // use place template
     360                $t = new StdClass();
     361                $t->uid = ++$placecount;
     362                $t->WPPost = $post->ID;
     363                $t->postId = $tag->postId;
     364                $t->placeJSON = $place_json;
     365                $t->options = array(
     366                  'showmap' => $showmap,
     367                  'isCustom' => $isCustom,               
     368                  'map_custom_style' => $customMapJson,
     369                  'map_icon_web' => wl_get_option("map_icon_web"),
     370                  'map_icon_directions' => wl_get_option("map_icon_directions"),
     371                  'font_place_name' => wl_get_option("font_place_name"),
     372                  'color_place_name' => wl_get_option("color_place_name"),
     373                  'size_place_name' => wl_get_option("size_place_name"),
     374                  'font_place_address' => wl_get_option("font_place_address"),
     375                  'color_place_address' => wl_get_option("color_place_address"),
     376                  'size_place_address' => wl_get_option("size_place_address"),
     377                  'where_image' => $whereImage
     378                );
     379               
     380                ob_start();
     381                include(dirname(__FILE__) . '/views/place-content-template.php');
     382                $resultContent = ob_get_contents();
     383                ob_end_clean();
     384               
     385                $t = null;
     386               
     387                return $resultContent;
     388
     389            }
     390           
     391            return $str;
     392            // $ShowPlaceAddress = get_post_meta( $postId, '_ShowPlaceAddress', true );
     393
     394        }   
    286395       
    287396        /* Callback for adding to the post itself
     
    305414            if(wl_get_option('map_custom_style') != ''){
    306415                $isCustom = 'true';
    307                 $customMapJson = base64_decode(wl_get_option("map_custom_style"));
     416                $customMapJson = wl_get_option("map_custom_style");
    308417            }
    309418           
     
    379488        }
    380489       
    381         /**
    382          * redundant
    383          */
    384         public function create_custom_category_if_not_exists( $categoryName ) {
    385             if ( !category_exists( $categoryName ) ) {
    386                 $category_id = wp_create_category( $categoryName );
    387                 return $category_id;
    388             } else {
    389                 return get_cat_ID( $categoryName );
    390             }
    391            
    392         }
    393        
    394        
    395        
    396490        public function addPlaceMetaSave( $postId ) {
    397491            $this->addPlaceMeta( $postId, 'save_post' );   
     
    404498        public function addPlaceMeta( $postId, $action ) {
    405499           
    406             //check to delete existing place info
    407500            if(!empty( $_POST['deletePlaceInfo'] )){
    408501                delete_post_meta($postId, '_PlaceSelected');
    409502                delete_post_meta($postId, '_isWLPlace');
    410503                update_post_meta( $postId, '_isWLPlace', 'false' );
    411             } else if( empty( $_POST['deletePlaceInfo'] ) && !empty( $_POST['PlaceSelected'] ) && isset( $_POST['isWLPlace'] )
    412                 && $_POST['isWLPlace'] == 'true' ) {
    413 
    414                 error_log("save case 1: [".$_POST['PlaceSelected']."]", 0);
     504            } else if( !empty( $_POST['PlaceSelected']) ) {
    415505
    416506                $category_id = $this->create_category_if_not_exists();             
     
    449539            }
    450540            else if($_POST['isWLPlace'] == 'false' || !isset( $_POST['isWLPlace']) ) {
    451                 error_log("save case 3", 0);
    452541                update_post_meta( $postId, '_isWLPlace', 'false' );
    453542            }
     
    455544   
    456545        }
     546       
     547        public function tagHandling($post_id) {
     548            if (!wp_is_post_revision($post_id)) {
     549                $post = get_post($post_id);
     550               
     551                $tags = WelocallyPlaces_Tag::parseText($post->post_content);
     552
     553                $proc = new WelocallyPlaces_TagProcessor();
     554                $result = $proc->processTags($tags, $post_id);
     555            }
     556        }
    457557       
    458558       
     
    470570        }   
    471571       
    472         /*
    473             should be parameterized
    474         */
    475         public function post_place_welocally($selectedPostJson, $action) {
    476 
    477            
    478             //set POST variables
    479             $url =  wl_server_base().'/rcadmin/wpp/publish';
    480            
    481            
    482             //open connection
    483             $ch = curl_init();
    484 
    485            
    486             //set the url, number of POST vars, POST data
    487             curl_setopt($ch,CURLOPT_URL,$url);
    488             curl_setopt($ch, CURLOPT_POST, true);
    489             curl_setopt($ch,CURLOPT_POSTFIELDS,$selectedPostJson);
    490             curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type: application/json; charset=utf-8', 'publisher-key: c1da06473823.oaklandly','welocally-baseurl: http://www.oaklandly.com','wp-action: '.$action));
    491            
    492             //execute post
    493             $result = curl_exec($ch);
    494            
    495             //close connection
    496             curl_close($ch);
    497         }
    498        
    499            
    500572
    501573        /// OPTIONS DATA
     
    507579
    508580        public function getSingleOption( $key ) {
    509             /*if($optionName) {         
    510                 $options = $this->getOptions();
    511                 return ( $options[$optionName] ) ? $options[$optionName] : $default;
    512             }*/
    513        
    514        
    515             //if( $this->latestOptions ) return $this->latestOptions[$key];
    516581            $options = $this->getOptions();
    517582            return $options[$key];
     
    545610        }
    546611       
    547        
     612        /*
     613         * just remove legacy meta
     614         */
     615        public function deletePostPlacesMeta($postId) {
     616           
     617            global $wpdb;
     618               
     619            //will recurse to elements                             
     620            if (is_array($postId)) {           
     621                foreach ($postId as $p) {                   
     622                    $this->deletePostPlacesMeta($p);
     623                }
     624            }           
     625       
     626            $wpdb->query(
     627                    "
     628                    DELETE FROM {$wpdb->prefix}postmeta
     629                    WHERE post_id = '$postId' AND meta_key='_PlaceSelected';
     630                    "
     631                    );
     632                               
     633        }
     634       
     635        /*
     636         * this is probably inefficient and could be done better with
     637         * some sort of join
     638         */
     639        public function deletePostPlaces($postId) {
     640           
     641            global $wpdb;
     642               
     643            //will recurse to elements                             
     644            if (is_array($postId)) {           
     645                foreach ($postId as $p) {                   
     646                    $this->deletePostPlaces($p);
     647                }
     648            }           
     649                   
     650            $postId = is_array($postId) ? $postId['ID'] : (is_object($postId) ? $postId->ID : intval($postId));
     651           
     652            //remove it from places table
     653            $post_places = $this->getPostPlaces($postId) ;
     654            foreach ($post_places as $place) {
     655
     656                $wpdb->query(
     657                    "
     658                    DELETE FROM {$wpdb->prefix}wl_places
     659                    WHERE wl_id = '$place->_id';
     660                    "
     661                    );             
     662            }               
     663           
     664            //remove it from posts
     665            $wpdb->query(
     666                    "
     667                    DELETE FROM {$wpdb->prefix}wl_places_posts
     668                    WHERE post_id = $postId;
     669                    "
     670                    );       
     671        }
     672       
     673       
     674        public function getPostPlaces($postId) {
     675            global $wpdb;
     676           
     677            if (is_array($postId)) {
     678                $places = array();
     679               
     680                foreach ($postId as $p) {
     681                    if (is_object($p) || is_array($p)) {
     682                        $p_ = (array) $p;
     683                        $places = $places + $this->getPostPlaces($p_['ID']);
     684                    } else if (is_int($p)) {
     685                        $places = $places + $this->getPostPlaces($p);
     686                    }
     687                }
     688               
     689                return $places;
     690            }
     691           
     692            $postId = is_array($postId) ? $postId['ID'] : (is_object($postId) ? $postId->ID : intval($postId));
     693           
     694            $places = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT place FROM {$wpdb->prefix}wl_places p INNER JOIN {$wpdb->prefix}wl_places_posts pp ON p.id = pp.place_id WHERE pp.post_id = %d", $postId));
     695           
     696            if ($places)
     697                return array_map('json_decode', $places);
     698               
     699            return array();
     700        }   
     701       
     702        public function getPostPlacesMeta($postId) {
     703            global $wpdb;
     704           
     705            if (is_array($postId)) {
     706                $places = array();
     707               
     708                foreach ($postId as $p) {
     709                    if (is_object($p) || is_array($p)) {
     710                        $p_ = (array) $p;
     711                        $places = $places + $this->getPostPlacesMeta($p_['ID']);
     712                    } else if (is_int($p)) {
     713                        $places = $places + $this->getPostPlacesMeta($p);
     714                    }
     715                }
     716               
     717                return $places;
     718            }
     719           
     720            $postId = is_array($postId) ? $postId['ID'] : (is_object($postId) ? $postId->ID : intval($postId));
     721           
     722            $places = $wpdb->get_col($wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = %d and meta_key='_PlaceSelected'", $postId));
     723           
     724            if ($places)
     725                //return array_map('json_decode', $places);
     726                return json_decode($places[0]);
     727               
     728            return array();
     729        }   
    548730       
    549731    }
     732   
    550733    global $wlPlaces;
    551734    $wlPlaces = new WelocallyPlaces();
  • welocally-places/trunk/welocally-places.php

    r476641 r514360  
    44Plugin Name: Welocally Places
    55Plugin URI: http://www.welocally.com/wordpress/?page_id=2
    6 Description: The Welocally Places plugin lets easily associate places for our 21M POI database without geocoding. The map widget makes it easy for your users to find the places your are writing about on a map.
    7 Version: 1.0.15
    8 Author: Welocally Inc.
     6Description: The Welocally Places plugin lets easily associate places from our 21M POI database without manual geocoding. The map widget makes it easy for your users to find the places your are writing about on a map.
     7Version: 1.1.16
     8Author: Welocally
    99Author URI: http://welocally.com
    1010License: GPL2
     11Notes: test hook 6
    1112*/
    1213
     
    1920add_action('wp_ajax_get_places', 'welocally_getplaces');
    2021add_action('wp_ajax_remove_token', 'welocally_remove_token');
     22add_action('wp_ajax_save_place', 'welocally_save_place');
     23
     24//catgeories
     25add_action('wp_ajax_get_classifiers_types', 'welocally_get_classifiers_types');
     26add_action('wp_ajax_get_classifiers_categories', 'welocally_get_classifiers_categories');
     27add_action('wp_ajax_get_classifiers_subcategories', 'welocally_get_classifiers_subcategories');
     28
     29
    2130add_action('wp_loaded', 'wl_self_deprecating_sidebar_registration');
    22 add_filter('the_excerpt', 'wl_get_excerpt_basic');
    23 
    24 function wl_get_excerpt_basic() {
    25     global $post;
    26     return wl_get_post_excerpt($post->ID);
    27 }
     31add_filter('the_excerpt', 'wl_get_excerpt_basic');
     32
     33// add filter's for plugin templates
     34add_filter('map_widget_template', 'wl_places_get_template_map_widget',10);
     35add_filter('list_widget_template', 'wl_places_get_template_list_widget',10);
     36add_filter('category_template', 'wl_places_get_template_category',10);
     37
    2838
    2939function wl_server_base() {
    3040    return wl_get_option("api_endpoint", null);
     41}
     42
     43
     44function welocally_getkey() {
     45
     46    $selectedPostJson = json_encode($_POST);
     47
     48    //set POST variables
     49    $url = wl_server_base() . '/admin/signup/2_0/plugin/key.json';
     50   
     51    error_log("url:".$url, 0);
     52
     53    $result_json = wl_do_curl_post($url, $selectedPostJson, array (
     54        'Content-Type: application/json; charset=utf-8'
     55    ));
     56   
     57    $result_model = json_decode($result_json);
     58   
     59
     60    die(); // this is required to return a proper result
     61}
     62
     63function welocally_register($selectedPostJson) {
     64
     65    $url = wl_server_base() . '/admin/signup/2_0/plugin/register';
     66   
     67    error_log("url:".$url, 0);
     68
     69    $result_json = wl_do_curl_post($url, $selectedPostJson, array (
     70        'Content-Type: application/json; charset=utf-8'
     71    ), true);
     72
     73    return $result_json;
     74}
     75
     76
     77function welocally_save_place() {
     78
     79    $placeToSave = $_POST['place'];
     80    $placeToSave['properties']['name'] = stripslashes($_POST['place']['properties']['name']);
     81    $placeToSave['properties']['address'] = stripslashes($_POST['place']['properties']['address']);
     82   
     83    $selectedPostJson = json_encode($placeToSave);
     84    error_log("place 1:".print_r($placeToSave, true),0);
     85    error_log("place 2:".strval($selectedPostJson),0);
     86
     87    //set POST variables
     88    $url = wl_server_base() . '/geodb/place/1_0/';
     89   
     90    error_log("url:".$url, 0);
     91
     92    $result_json = wl_do_curl_put($url, $selectedPostJson, array (
     93        'Content-Type: application/json; charset=utf-8',
     94        'site-key:' . wl_get_option('siteKey', null),
     95        'site-token:' . wl_get_option('siteToken', null)
     96    ));
     97   
     98    $result_model = json_decode($result_json);
     99
     100    die(); // this is required to return a proper result
     101}
     102
     103function welocally_getplaces() {
     104
     105   
     106    $url = wl_server_base() .'/geodb/place/1_0/search.json?'.http_build_query($_GET);
     107   
     108    error_log("url:".$url, 0);
     109
     110    $result_json = wl_do_curl_get($url, array (
     111        'Content-Type: application/json; charset=utf-8',
     112        'site-key:' . wl_get_option('siteKey', null),
     113        'site-token:' . wl_get_option('siteToken', null)
     114    ));
     115
     116    die(); // this is required to return a proper result
     117}
     118
     119function welocally_get_classifiers_types() {
     120
     121   
     122    $url = wl_server_base() .'/geodb/classifier/1_0/types.json';
     123   
     124    error_log("url:".$url, 0);
     125
     126    $result_json = wl_do_curl_get($url, array (
     127        'Content-Type: application/json; charset=utf-8',
     128        'site-key:' . wl_get_option('siteKey', null),
     129        'site-token:' . wl_get_option('siteToken', null)
     130    ));
     131
     132    die(); // this is required to return a proper result
     133}
     134
     135function welocally_get_classifiers_categories() {
     136
     137
     138    $url = wl_server_base() .'/geodb/classifier/1_0/categories.json?'.http_build_query($_GET);
     139   
     140    error_log("url:".$url, 0);
     141
     142    $result_json = wl_do_curl_get($url, array (
     143        'Content-Type: application/json; charset=utf-8',
     144        'site-key:' . wl_get_option('siteKey', null),
     145        'site-token:' . wl_get_option('siteToken', null)
     146    ));
     147
     148    die(); // this is required to return a proper result
     149}
     150
     151function welocally_get_classifiers_subcategories() {
     152
     153    $url = wl_server_base() .'/geodb/classifier/1_0/subcategories.json?'.http_build_query($_GET);
     154   
     155    error_log("url:".$url, 0);
     156
     157    $result_json = wl_do_curl_get($url, array (
     158        'Content-Type: application/json; charset=utf-8',
     159        'site-key:' . wl_get_option('siteKey', null),
     160        'site-token:' . wl_get_option('siteToken', null)
     161    ));
     162
     163    die(); // this is required to return a proper result
     164}
     165
     166//-------- GET ------------
     167
     168function wl_do_curl_get($url, $headers){
     169    error_log("wl_do_curl_get url:".$url, 0);
     170   
     171    $result_json = '';
     172    if (preg_match("/https/", $url)) {
     173        $result_json = wl_do_curl_get_https($url, $headers);
     174    } else {
     175        $result_json = wl_do_curl_get_http($url, $headers);
     176    }
     177
     178    return $result_json;
     179}
     180
     181function wl_do_curl_get_http($url, $headers) {
     182    //open connection
     183    $ch = curl_init();
     184
     185    //set the url, number of POST vars, POST data
     186    curl_setopt($ch, CURLOPT_URL, $url);
     187    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     188
     189    //execute post
     190    $result_json = curl_exec($ch);
     191
     192    curl_close($ch);
     193
     194    return $result_json;
     195}
     196
     197
     198function wl_do_curl_get_https($https_url, $headers) {
     199
     200    //open connection
     201    $ch = curl_init();
     202
     203    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     204    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     205    curl_setopt($ch, CURLOPT_CAINFO, NULL);
     206    curl_setopt($ch, CURLOPT_CAPATH, NULL);
     207
     208    //set the url, number of POST vars, POST data
     209    curl_setopt($ch, CURLOPT_URL, $https_url);
     210    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     211
     212    //execute post
     213    $result_json = curl_exec($ch);
     214
     215    curl_close($ch);
     216
     217    return $result_json;
     218}
     219
     220//-------- PUT ------------
     221function wl_do_curl_put($url, $selectedPostJson, $headers) {
     222    error_log("PUT url:".$url." JSON:".$selectedPostJson, 0);
     223
     224    $result_json = '';
     225    if (preg_match("/https/", $url)) {
     226        $result_json = wl_do_curl_put_https($url, $selectedPostJson, $headers);
     227    } else {
     228        $result_json = wl_do_curl_put_http($url, $selectedPostJson, $headers);
     229    }
     230
     231    return $result_json;
     232}
     233
     234
     235
     236
     237function wl_do_curl_put_http($url, $selectedPostJson, $headers) {
     238    //open connection
     239    $ch = curl_init();
     240   
     241    $requestLength = strlen($selectedPostJson);
     242
     243    $fh = fopen('php://memory', 'rw');
     244    fwrite($fh, $selectedPostJson);
     245    rewind($fh);
     246
     247    //set the url, number of POST vars, POST data
     248    curl_setopt($ch, CURLOPT_URL, $url);
     249    curl_setopt($ch, CURLOPT_INFILE, $fh);
     250    curl_setopt($ch, CURLOPT_INFILESIZE, $requestLength);
     251    curl_setopt($ch, CURLOPT_PUT, true);
     252    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     253
     254    //execute put
     255    $result_json = curl_exec($ch);
     256
     257    curl_close($ch);
     258   
     259    fclose($fh);
     260
     261    return $result_json;
     262}
     263
     264function wl_do_curl_put_https($https_url, $selectedPostJson, $headers) {
     265
     266    //open connection
     267    $ch = curl_init();
     268   
     269    $requestLength = strlen($selectedPostJson);
     270
     271    $fh = fopen('php://memory', 'rw');
     272    fwrite($fh, $selectedPostJson);
     273    rewind($fh);
     274
     275    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     276    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     277    curl_setopt($ch, CURLOPT_CAINFO, NULL);
     278    curl_setopt($ch, CURLOPT_CAPATH, NULL);
     279
     280    //set the url, number of POST vars, POST data
     281    curl_setopt($ch, CURLOPT_URL, $https_url);
     282    curl_setopt($ch, CURLOPT_INFILE, $fh);
     283    curl_setopt($ch, CURLOPT_INFILESIZE, $requestLength);
     284    curl_setopt($ch, CURLOPT_PUT, true);
     285    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     286
     287    //execute put
     288    $result_json = curl_exec($ch);
     289
     290    curl_close($ch);
     291   
     292    fclose($fh);
     293
     294    return $result_json;
     295}
     296
     297
     298
     299
     300
     301
     302//-------- POST ------------
     303function wl_do_curl_post($url, $selectedPostJson, $headers, $returnxfer = false) {
     304    $result_json = '';
     305    if (preg_match("/https/", $url)) {
     306        $result_json = wl_do_curl_post_https($url, $selectedPostJson, $headers,$returnxfer);
     307    } else {
     308        $result_json = wl_do_curl_post_http($url, $selectedPostJson, $headers,$returnxfer);
     309    }
     310
     311    return $result_json;
     312}
     313
     314function wl_do_curl_post_http($url, $selectedPostJson, $headers, $returnxfer = false) {
     315    //open connection
     316    $ch = curl_init();
     317
     318    //set the url, number of POST vars, POST data
     319    curl_setopt($ch, CURLOPT_URL, $url);
     320    curl_setopt($ch, CURLOPT_POST, true);
     321    curl_setopt($ch, CURLOPT_POSTFIELDS, $selectedPostJson);
     322    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     323    curl_setopt($ch, CURLOPT_RETURNTRANSFER, $returnxfer);
     324   
     325
     326    //execute post
     327    $result_json = curl_exec($ch);
     328
     329    curl_close($ch);
     330
     331    return $result_json;
     332}
     333
     334function wl_do_curl_post_https($https_url, $selectedPostJson, $headers, $returnxfer = false) {
     335
     336    //open connection
     337    $ch = curl_init();
     338
     339    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     340    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     341    curl_setopt($ch, CURLOPT_CAINFO, NULL);
     342    curl_setopt($ch, CURLOPT_CAPATH, NULL);
     343    curl_setopt($ch, CURLOPT_RETURNTRANSFER, $returnxfer);
     344
     345    //set the url, number of POST vars, POST data
     346    curl_setopt($ch, CURLOPT_URL, $https_url);
     347    curl_setopt($ch, CURLOPT_POST, true);
     348    curl_setopt($ch, CURLOPT_POSTFIELDS, $selectedPostJson);
     349    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     350
     351    //execute post
     352    $result_json = curl_exec($ch);
     353
     354    curl_close($ch);
     355
     356    return $result_json;
     357}
     358
     359
     360
     361//----- end of neworking section ----------//
     362
     363function wl_debug() {
     364    $args = func_get_args();
     365   
     366    echo '<pre>';
     367    foreach ($args as $arg) {
     368        print_r($arg);
     369    }
     370    echo '</pre>';
     371}
     372
     373function wl_debug_e() {
     374    call_user_func_array('wl_debug', func_get_args());
     375    exit;
    31376}
    32377
     
    59404
    60405    $selectedPostJson = json_encode($_POST);
    61     syslog(LOG_WARNING, "A" . var_export($selectedPostJson, true));
    62 
     406   
    63407    $options = wl_get_options();
    64408
     
    70414}
    71415
    72 function welocally_getkey() {
    73 
    74     $selectedPostJson = json_encode($_POST);
    75     //syslog(LOG_WARNING, "A" . var_export($selectedPostJson, true));
    76 
    77     //set POST variables
    78     $url = wl_server_base() . '/rcadmin/signup/plugin/key.json';
    79    
    80     error_log("url:".$url, 0);
    81 
    82     $result_json = wl_do_curl($url, $selectedPostJson, array (
    83         'Content-Type: application/json; charset=utf-8'
    84     ));
    85 
    86     die(); // this is required to return a proper result
    87 }
    88 
    89 function wl_do_curl($url, $selectedPostJson, $headers) {
    90     $result_json = '';
    91     if (preg_match("/https/", $url)) {
    92         $result_json = wl_do_curl_https($url, $selectedPostJson, $headers);
    93     } else {
    94         $result_json = wl_do_curl_http($url, $selectedPostJson, $headers);
    95     }
    96 
    97     return $result_json;
    98 }
    99 
    100 function wl_do_curl_http($url, $selectedPostJson, $headers) {
    101     //open connection
    102     $ch = curl_init();
    103 
    104     //set the url, number of POST vars, POST data
    105     curl_setopt($ch, CURLOPT_URL, $url);
    106     curl_setopt($ch, CURLOPT_POST, true);
    107     curl_setopt($ch, CURLOPT_POSTFIELDS, $selectedPostJson);
    108     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    109 
    110     //execute post
    111     $result_json = curl_exec($ch);
    112 
    113     curl_close($ch);
    114 
    115     return $result_json;
    116 }
    117 
    118 function wl_do_curl_https($https_url, $selectedPostJson, $headers) {
    119 
    120     //open connection
    121     $ch = curl_init();
    122 
    123     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    124     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    125     curl_setopt($ch, CURLOPT_CAINFO, NULL);
    126     curl_setopt($ch, CURLOPT_CAPATH, NULL);
    127 
    128     //set the url, number of POST vars, POST data
    129     curl_setopt($ch, CURLOPT_URL, $https_url);
    130     curl_setopt($ch, CURLOPT_POST, true);
    131     curl_setopt($ch, CURLOPT_POSTFIELDS, $selectedPostJson);
    132     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    133 
    134     //execute post
    135     $result_json = curl_exec($ch);
    136 
    137     curl_close($ch);
    138 
    139     return $result_json;
    140 }
    141 
    142 function welocally_getplaces() {
    143 
    144     $selectedPostJson = json_encode($_POST);
    145     syslog(LOG_WARNING, "A" . var_export($selectedPostJson, true));
    146 
    147     //set POST variables http://108.200.49.246/
    148     $url = wl_server_base() . '/rcadmin/publisher/place/queryplaces.json';
    149 
    150     $result_json = wl_do_curl($url, $selectedPostJson, array (
    151         'Content-Type: application/json; charset=utf-8',
    152         'site-key:' . wl_get_option('siteKey', null),
    153         'site-token:' . wl_get_option('siteToken', null)
    154     ));
    155 
    156     die(); // this is required to return a proper result
    157 }
    158 
    159 function welocally_add_place() {
    160 
    161     $selectedPostJson = json_encode($_POST);
    162 
    163     //set POST variables
    164     $url = wl_server_base() . '/rcadmin/publisher/place/addplace.json';
    165 
    166     $result_json = wl_do_curl($url, $selectedPostJson, array (
    167         'Content-Type: application/json; charset=utf-8'
    168     ));
    169 
    170     die(); // this is required to return a proper result
    171 }
     416
    172417
    173418function welocally_requirements_check() {
     
    190435    }
    191436}
     437
     438function wl_get_excerpt_basic() {
     439    global $post;
     440    return wl_get_post_excerpt($post->ID);
     441}
     442
    192443
    193444function welocally_activate() {
     
    228479    }*/
    229480}
     481
    230482?>
Note: See TracChangeset for help on using the changeset viewer.