Plugin Directory

Changeset 708983


Ignore:
Timestamp:
05/07/2013 02:27:16 AM (13 years ago)
Author:
Sanskript
Message:

Delvelopment Checkin for Milestone 1.

Location:
soldpress/branches/0.9.5A
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • soldpress/branches/0.9.5A/adapter.php

    r704538 r708983  
    1717        $this->log = new Logging();
    1818        $wp_upload_dir = wp_upload_dir();
    19         $this->log->lfile($wp_upload_dir[basedir]. '/soldpress/soldpress-log.txt');
     19        $this->log->lfile($wp_upload_dir['basedir']. '/soldpress/soldpress-log.txt');
    2020       
    2121        $this->service= new phRETS();
     
    2626       
    2727        $cookie_file = 'soldpress';
    28         @touch(cookie_file);
    29         if (is_writable(cookie_file)) {
     28        @touch('cookie_file');
     29        if (is_writable('cookie_file')) {
    3030            $this->service->SetParam('cookie_file', 'soldpress');
    3131        }
     
    106106   
    107107    public function sync_residentialproperty($crit, $culture)
    108     {           
    109    
    110         //OPTIMIXATION: Get All Listing That Are Type property in a Array
    111         $this->WriteLog('OPTIMIXATION');
    112         $args2 = array(
    113                 'post_type' => 'property'
    114                 );
    115        
    116         $this->WriteLog('Get Data from service');   
    117         $posts_array2 = get_posts( $args2 ); // This can be optimized. //Reterive Only Once
    118         $this->WriteLog('Data Get');
    119         var_dump(count($posts_array2));     
    120         //var_dump($posts_array2);
     108    {   
     109        $this->WriteLog('Sync Start');
    121110        global $wpdb;
    122         $privates = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'property'");
    123         var_dump(count($privates));     
    124         var_dump($privates);   
    125 
    126         //11937214
    127        
    128     //  SELECT *,$wpdb->postmeta FROM $wpdb->posts $wpdb->postmeta WHERE $wpdb->posts.post_type = 'property';
    129 
    130      //   AND $wpdb->postmeta.meta_key = 'key1'   
    131      //   AND $wpdb->postmeta.meta_value = 'value1'*/
    132         return;
    133 
     111        $wpdb->query("set wait_timeout = 1200"); //Thank You (johnorourke) http://stackoverflow.com/questions/14782494/keep-losing-the-database-in-wordpress       
     112        $syncenabled = get_option("sc-sync-enabled",true);
     113        if($syncenabled != true){
     114                $this->WriteLog('Sync Disabled');
     115                return;
     116        }
     117       
    134118        //Get Time
    135119        //Get Culture
     
    138122        update_option( 'sc-sync-start',time() );
    139123        update_option( 'sc-sync-end','' );
    140        
    141         $this->WriteLog('Sync Start');
    142        
    143         echo $crit;
    144124
    145125        if($culture =='')
     
    148128        }
    149129
    150         $this->WriteLog('Getting Results');
    151        
    152         $results = $this->service->SearchQuery("Property","Property",$crit,array("Limit" => '100',"Culture" => $culture)); 
    153        
    154         $this->WriteLog('Reterived Results');
    155        
    156        
    157        
    158    
    159         while ($rets = $this->service->FetchRow($results)) {
    160 
     130        $this->WriteLog('service->Search' . $crit);
     131   
     132        //Get As Disconnect Array So We Don't Worry Abour Releasing The Adapter
     133        $properties = $this->service->Search("Property","Property",$crit,array("Limit" => '100',"Culture" => $culture));   
     134        $this->WriteLog('Retrieved Results');
     135
     136        //Get Disconnect Array of Current Post
     137        $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'property'");
     138        //Reset Data
     139        $total = count($properties);
     140        $count = 0;
     141        $user_id = get_current_user_id();
     142        //Loop Data
     143        foreach ($properties as &$rets) {
     144           
     145            $count = $count + 1;
     146           
    161147            $ListingKey = $rets['ListingKey'];
    162             echo 'ListingKey: ' . $ListingKey .'<br>';//
    163                    
    164             //Check And See If We Have A Post Mathing The Listing Key
    165             $args = array(
    166                 'post_type' => 'property',
    167                 'meta_query' => array(
    168                     array(
    169                         'key' => 'ListingKey',
    170                         'value' => $ListingKey,)
    171                 )
    172              );
    173              
    174             $posts_array = get_posts( $args ); // This can be optimized. //Reterive Only Once
    175            
     148            $this->WriteLog('$ListingKey' . $ListingKey);
     149            $post = ''; //Want To Mat use unset
     150            foreach($posts_array as $struct) {         
     151                if ($ListingKey == $struct->post_name) {
     152                    $post = $struct;
     153                    break;
     154                }
     155            }
     156   
    176157            $title = $rets['UnparsedAddress'] .' (' . $rets['ListingId'] .')';
    177158            $content = time();
    178        
    179             if( $posts_array ) {
    180            
    181                                
    182                 $post = $posts_array[0];
    183                
    184             /*  if($post->ModificationTimestamp == $rets['ModificationTimestamp'])
    185                 {
    186                     $this->WriteLog($post->ID . ' No Change To Record' . $post->ModificationTimestamp );
    187                
    188                 }
    189                 else
    190                 {*/
     159           
     160            if($post != '')
     161            {                                       
    191162                    $post->post_title = $title;
    192163                    $post->post_content  = $content . 'Updated';
    193164                    $post->post_name = $ListingKey;
    194                     wp_update_post($post);//
     165                    $post->post_date = $rets['ModificationTimestamp'];
     166
     167                    wp_update_post($post);
     168                    $post_id = $post->ID;
     169                    $this->WriteLog('Update Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total); 
    195170                   
    196                     $post_id = $post->ID;
    197                     $this->WriteLog('Update ' . $ListingKey . '-' . $post_id);
     171                    //$this->WriteLog('Delete PostMeta' . $ListingKey . '-' . $post_id);               
     172                    $deleteQuery = $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key like %s",$post_id,'dfd_%'); //Delte Only ListingData
     173                    $wpdb->query($deleteQuery);
     174
     175                    //$this->WriteLog('Insert PostMeta' . $ListingKey . '-' . $post_id);
     176                    $meta_values = array();
    198177                   
    199                     foreach($rets as $key => &$val) {                   
    200                         //update_post_meta($post_id,$key, $val);   
    201 
    202                         //Don't Update Listing Key
    203                         if($key != 'ListingKey'){
    204                             //Direct Query Still Causing Problems
    205                             global $wpdb;           
    206                             $wpdb->query("UPDATE $wpdb->postmeta
    207                                           SET meta_value = '$val'
    208                                           WHERE post_id = $post_id
    209                                             AND meta_key = '$key'");
     178                    //For Speed Optimization we Only Update Records That Have Values This Cuts down on the number of quires we will send to the server
     179                    foreach($rets as $key => &$value){
     180                        if($value != ''){
     181                            $meta_values[] = $wpdb->prepare('(%s, %s, %s)', $post_id, 'dfd_'.$key, $value);
    210182                        }
    211                    
    212                     }
    213                 //}
    214 
    215             }
    216             else{               
     183                    }                           
     184                    $values = implode(', ', $meta_values);
     185                    $wpdb->query("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $values");     
     186            }
     187            else
     188            {               
     189               
    217190               
    218191                $post = array(
     
    220193                      'post_content'  => $content,
    221194                      'post_status'   => 'publish',
    222                       'post_author'   => 1,
    223                       'post_type'   => 'property'
     195                      'post_author'   => $user_id,
     196                      'post_type'   => 'property',
     197                      'post_name' => $ListingKey,
     198                      'post_date' => $rets['ModificationTimestamp']
    224199                );
    225                
    226                 $post_id = wp_insert_post( $post );
    227                
    228                 $this->WriteLog('Insert ' . $ListingKey);
    229         //      try{
    230                    
    231                 /*  foreach($rets as $key => &$val) {   
    232                    
    233                         try
    234                         {
    235                             add_post_meta($post_id,$key, $val);
    236                         }
    237                         catch(Exception $e){
    238                        
    239                             $this->WriteLog('Error Post Meta Insert ' . $ListingKey . $key . $e);
    240                         }
    241                     }*/
    242                    
    243                     global $wpdb;
     200           
     201                $post_id = wp_insert_post( $post, $wp_error);
     202
     203                if($post_id == 0){
     204                    $this->WriteLog('Insert Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total . "Error:" . $wp_error . 'User:' . $user_id); 
     205                    //$this->WriteLog($wpdb->last_error);               
     206                }
     207                else
     208                {
     209
     210                    $this->WriteLog('Insert Post' . $ListingKey . '-' . $post_id . ' Record -' .$count . ' of ' . $total); 
     211                                   
    244212                    $meta_values = array();
    245213                    foreach($rets as $key => &$value){
    246                         $meta_values[] = $wpdb->prepare('(%s, %s, %s)', $post_id, $key, $value);
    247                     }                           
    248                     $values = implode(', ', $meta_values);                 
     214                        $meta_values[] = $wpdb->prepare('(%s, %s, %s)', $post_id,'dfd_'. $key, $value);
     215                    }                           
     216                    $values = implode(', ', $meta_values);             
    249217                    $wpdb->query("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $values");
    250         //      }
    251         //      catch (Exception $e){
    252         //          update_option( 'sc-sync-error',$e );
    253         //      }
    254                                
    255             }
    256 
    257         //  $this->sync_propertyobject($rets['ListingKey'], 'Photo',$post_id);
     218                }                               
     219            }
     220
    258221            update_post_meta($post_id,'sc-sync-meta-end', time());         
    259222        }   
     223       
    260224
    261225        $this->WriteLog('End Sync');       
    262            
    263         $this->service->FreeResult($results);
    264 
     226       
    265227        update_option( 'sc-sync-end',time() );
    266228        update_option( 'sc-status', false );
     
    269231    }
    270232   
     233    public function sync_pictures()
     234    {
     235        echo 'pics';
     236        global $wpdb;
     237        $wpdb->query("set wait_timeout = 1200");
     238        $this->WriteLog('Begin Picture Sync'); 
     239        //TODO:// we should be able to speed this up by only joining to the key
     240        $posts_array = $wpdb->get_results("select ID,post_name from $wpdb->posts where post_type = 'property'");
     241       
     242        foreach($posts_array as $listing)
     243        {       
     244                $post_id = $listing->ID;
     245                //Check and see if there if property data needs to be synced
     246                $meta = get_post_meta( $post_id ,'sc-sync-picture');
     247           
     248                $listingKey = $listing->post_name;
     249                if($listingKey){ //If Someone manually adds a listing the key is wrong
     250                if($meta)
     251                {       
     252                    $this->WriteLog('Photo Record is Synced' .$meta . 'listingkey' .$listingKey );
     253                }else
     254                {
     255                   
     256                    $this->WriteLog('Meta' .$meta . 'listingkey' .$listingKey );
     257                    $this->WriteLog('Begin Picture Sync' . $post_id );
     258                    $this->sync_propertyobject($listingKey, 'Photo',$post_id);
     259                    update_post_meta($post_id,'sc-sync-picture', true);
     260               
     261                }
     262                }
     263        }
     264       
     265        $this->WriteLog('End Picture Sync');   
     266    }
     267   
    271268    public function sync_propertyobject($id, $type, $post_id)
    272     {
    273    
     269    {   
    274270        $args = array(
    275271       'post_type' => 'attachment',
     
    283279         if ( $attachments ) {
    284280            foreach ( $attachments as $attachment ) {
    285              //  echo '<li>';
    286              //  echo wp_get_attachment_image( $attachment->ID, 'full' );
    287              //  echo '<p>';
    288              //  echo apply_filters( 'the_title', $attachment->post_title );
    289              //  echo '</p></li>';
    290281               wp_delete_attachment( $attachment->ID, true );
    291                //Let's Delete All The Attachments
    292282              }
    293283         }
    294284   
    295285        $record = $this->service->GetObject("Property", $type, $id);
    296    
    297286        $isAttached = false;
    298287        foreach($record as &$image)
    299288        {
    300         //  echo $image["Content-Type"];
    301         //  echo $image["Object-ID"];
    302         //  echo $image["Content-ID"];
    303289           
    304290            $filename = $image["Content-ID"] .'-' . $type .'-'.$image["Object-ID"]. '.jpg';         
    305291            $wp_upload_dir = wp_upload_dir();
    306             //Check Directory
    307             $filePath = $wp_upload_dir[basedir]. '/soldpress/'.$filename;
    308          
    309             file_put_contents($filePath,$image["Data"]); //We Change This In Settings
    310            
    311            
    312             //Need a little work
    313             //Check if files exists
    314             //If attachement is already attached do nothing with the meta data just update the file.
    315                
    316         //  echo "Attachmet" . $filePath;
    317            
     292            $filePath = $wp_upload_dir['basedir']. '/soldpress/'.$filename;       
     293            file_put_contents($filePath,$image["Data"]); //We Change This In Settings           
    318294            $wp_filetype = wp_check_filetype(basename($filename), null );
    319295            $wp_upload_dir = wp_upload_dir();
     
    397373    private function WriteLog($text)
    398374    {
    399         update_option( 'sc-sync-status',$text );
     375        //update_option( 'sc-sync-status',$text );
    400376        $this->log->lwrite($text.PHP_EOL);
    401377    }
  • soldpress/branches/0.9.5A/custom_field_types.php

    r704538 r708983  
    3535            'has_archive'         => true,
    3636            'exclude_from_search' => false,
    37             'publicly_queryable'  => true,
     37            'publicly_queryable'  => true,     
    3838            'capability_type'     => 'page',
    3939        );
     
    4141        register_post_type( 'property', $args );
    4242    }
    43 
    44 // Hook into the 'init' action
    45 add_action('init', 'custom_post_type', 0 );
    46 add_action("admin_init", "admin_init");
    47  
    48 function admin_init()
    49 {
    50 // add_meta_box( 'listing_meta_boxes', 'Property Details', 'listing_meta_boxes', 'property', 'normal', 'high' );
    51 }
    5243
    5344function listing_meta_boxes() {
     
    6859    }
    6960
     61// Hook into the 'init' action
     62add_action('init', 'custom_post_type', 0 );
     63add_action("admin_init", "admin_init");
     64 
     65function admin_init()
     66{
     67// add_meta_box( 'listing_meta_boxes', 'Property Details', 'listing_meta_boxes', 'property', 'normal', 'high' );
     68}
     69
     70
    7071?>
  • soldpress/branches/0.9.5A/settings.php

    r703015 r708983  
    1313    register_setting( 'sc-settings-group', 'sc-url' );
    1414    register_setting( 'sc-settings-group', 'sc-template' );
    15 //  register_setting( 'sc-settings-group', 'sc-lastupdate' );
    16 //  register_setting( 'sc-settings-group', 'sc-status' );
     15    register_setting( 'sc-settings-group', 'sc-language' );
     16    register_setting( 'sc-settings-group', 'sc-sync-enabled' );
    1717}
    1818
     
    4444        <td><input type="text" class="regular-text" name="sc-template" value="<?php echo get_option('sc-template','wp-content/plugins/soldpress/template/'); ?>" /></td>
    4545        </tr>
     46        <tr valign="top">
     47        <th scope="row">Language</th>
     48        <td><input type="text" class="regular-text" name="sc-template" value="<?php echo get_option('sc-language','en-CA'); ?>" /></td>
     49        </tr>
     50        <tr valign="top">
     51        <th scope="row">Sync Enabled</th>
     52        <td><input type="text" class="regular-text" name="sc-template" value="<?php echo get_option('sc-sync-enabled','1'); ?>" /></td>
     53        </tr>
    4654    <tr valign="top">
    4755        <th scope="row">Last Update</th>
     
    4957        </tr>
    5058    </table>
    51     Status : <?php echo get_option('sc-status' ) ?>
    52      Start : <?php echo get_option('sc-sync-start' ) ?>
    53       End : <?php echo get_option('sc-sync-end' ) ?>
    54       Error : <?php echo get_option('sc-sync-error' ) ?>
    5559    <?php submit_button(); ?> 
    5660</form>
     
    6064    <?php submit_button('Manual Sync', 'secondary', 'sync', false); ?>
    6165    <?php submit_button('Clear Listings', 'secondary', 'delete', false); ?>
    62    
    63    
    6466</form>
     67<br><br>
     68    <?php if (get_option('sc-status' ) == true) { ?>
     69        <div id="message" class="updated"><p>CREA Data Sync Active</p>
     70           <ul>
     71                <li>Status : <?php echo get_option('sc-status' ) ?></li>
     72                <li>Start : <?php echo get_option('sc-sync-start' ) ?></li>
     73                <li>End : <?php echo get_option('sc-sync-end' ) ?></li>
     74                <li>Error : <?php echo get_option('sc-sync-error' ) ?> </li>     
     75                <li>Discription : <?php echo get_option('sc-sync-status' ) ?> </li>
     76            </ul>
     77        </div>
     78    <?php } ?> 
    6579<br><br>
    6680<div>
     
    6882<br>
    6983&copy; 2013 Sanskript Solution, Inc.</div>
     84
     85 <div class = "postbox">
     86            <div class = "handlediv">
     87                <br>
     88            </div>
     89            <h3 class = "hndle"><span><?php _e('Debug Information', 'bulk-delete'); ?></span></h3>
     90            <div class = "inside">
     91            <p>Debug</p>
     92                <table cellspacing="10">
     93                    <tr>
     94                        <th align = "right"><?php _e('Available memory size ', 'bulk-delete');?></th>
     95                        <td><?php echo ini_get( 'memory_limit' ); ?></td>
     96                    </tr>
     97                    <tr>
     98                        <th align = "right"><?php _e('Script time out ', 'bulk-delete');?></th>
     99                        <td><?php echo ini_get( 'max_execution_time' ); ?></td>
     100                    </tr>
     101                    <tr>
     102                        <th align = "right"><?php _e('Script input time ', 'bulk-delete'); ?></th>
     103                        <td><?php echo ini_get( 'max_input_time' ); ?></td>
     104                    </tr>
     105            <tr>
     106                        <th align = "right"><?php _e('My Sql Connect Timeou ', 'bulk-delete'); ?></th>
     107                        <td><?php echo ini_get( 'mysql.connect_timeout' ); ?></td>
     108                    </tr>
     109
     110                </table>
     111            </div>
     112        </div>
     113       
    70114<?php
    71115
     116    add_action( 'in_admin_footer', 'admin_footer' );
     117    /**
     118     * Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
     119     */
     120    function admin_footer() {
     121        $plugin_data = get_plugin_data( __FILE__ );
     122        printf('%1$s ' . __("plugin", 'soldpress') .' | ' . __("Version", 'soldpress') . ' %2$s | '. __('by', 'soldpress') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
     123    }
    72124//$date = new DateTime();
    73125//echo $date->getTimestamp();
     
    84136    if (isset($_POST["sync"])) { 
    85137   
    86         $adapter= new soldpress_adapter();
    87         if($adapter->connect())
    88         {
    89             return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z","");     
    90         }
     138         soldpress_listintgs();
    91139    }
    92140   
    93141    if (isset($_POST["delete"])) { 
     142
     143    /*  global $wpdb;
     144        $meta_values = array();
     145foreach ($metadata as $key => $value) {
     146    $meta_values[] = $wpdb->prepare('( %s, %s, %s)', $post_id, $key, $value);
     147    }
     148    $values = implode(', ', $meta_values);
     149    $wpdb->query("INSERT INTO $wpdb->postmeta ($post_id, meta_key, meta_value) VALUES $values");
     150*/
     151
    94152        echo 'delete';
    95153        $mycustomposts = get_posts( array( 'post_type' => 'property', 'numberposts' => 500) );
  • soldpress/branches/0.9.5A/single-property.php

    r704538 r708983  
    1 <?php
    2  get_header();
    3 ?>
     1<div class="alert alert-warning"><strong>This is a template for a simple listing website. Use it as a starting point to create something more unique </div>
    42
    5 <div class="sixteen columns outercontainer bigheading">
    6     <div class="four columns alpha">
    7         &nbsp;
    8     </div>
    9     <div class="twelve columns omega">
    10         <h2 id="title" class="blogtitle"><?php the_title(); ?></h2>
    11     </div>
    12 </div> 
     3<?php get_header(); ?>
     4<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
     5<h1><?php the_title(); ?></h1>
     6<div class="container-fluid">
     7    <div class="alert alert-success">
     8    <div class="row">
     9    <div class="span4">MLS®: <?php echo get_post_meta($post->ID,'dfd_ListingId',true); ?> </div>   
     10    <div class="span4 pull-left">For Sale: $<?php echo get_post_meta($post->ID,'dfd_ListPrice',true); ?></div>
     11    </div></div>
     12
     13<div class="row-fluid">
     14<div class="span8">
     15<p>
     16<div class="cycle-slideshow"
     17    data-cycle-fx=scrollHorz
     18    data-cycle-timeout=0
     19    data-cycle-pager="#adv-custom-pager"
     20    data-cycle-pager-template="<a href='#'><img src='{{src}}' width=40 height=40></a>">
     21    <?php
     22$photos = get_children( array('post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
     23    if($photos){
     24        foreach ($photos as $photo) {
     25            echo '<image src="' . wp_get_attachment_url($photo->ID,'thumbnail') . '">';
     26        }
     27    }
     28    ?>         
     29<div id=adv-custom-pager class="center external"></div>
     30</div></p>
     31
     32<p><div class="alert alert-success"><?php echo get_post_meta($post->ID,'dfd_UnparsedAddress',true); ?> <?php echo get_post_meta($post->ID,'dfd_City',true); ?>, <?php echo get_post_meta($post->ID,'dfd_StateOrProvince',true); ?> <?php echo get_post_meta($post->ID,'dfd_PostalCode',true); ?></div></p>
     33<p><?php echo get_post_meta($post->ID,'dfd_PublicRemarks',true); ?></p>
    1334
    1435
    15 <div class="sixteen columns outercontainer" id="content">
    16     <div class="four columns alpha" id="leftsidebar">
    17         <?php get_sidebar() ?>
    18     </div>
    19    
    20     <div class="twelve columns omega"> 
    21    
    22         <?php
    23                 $arr_sliderimages = get_gallery_images();
    24             ?> 
    25         <?php if (count($arr_sliderimages) > 0) { ?>
    26                     <div id="sliderimage">
    27                         <?php if(count($arr_sliderimages) > 1) { ?>
    28                             <div class="imagehover"></div>
    29                         <?php } ?>
    30                        
    31                         <?php
    32                             $count = 1;
    33                             $hide = "";
    34                             foreach ($arr_sliderimages as $image) {
    35                             if($count != 1) {
    36                                     $hide = "style='display: none;'";
    37                                 }
    38                                 $resized = aq_resize($image, 700, 400,true);
    39                                 $resizedthumb = aq_resize($image, 62, 62,true);
    40                             ?>
    41                            
    42                             <div class="image" <?php echo $hide; ?>>
    43                                 <img class="detailpagebigimage" alt="" rel="<?php echo $resizedthumb ?>" src="<?php echo $resized ?>" />
    44                             </div>
    45                            
    46                         <?php
    47                         $count = $count + 1;
    48                         } ?>
    49                     </div><!-- end sliderimage -->
    50                 <?php } ?>
    51                
    52         <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     
    53              <div <?php post_class() ?>    id="post-<?php echo the_ID(); ?>">
    54        
    55                     <?php if (get_option('wp_showblogimage') == 'show') { ?>
    56                         <?php
    57                         if ( has_post_thumbnail() ) {
    58                            
    59                             the_post_thumbnail('medium');
    60                         }  ?>
    61                      <?php } ?>
    62                    
    63 <?php include get_template_directory() . '/includes/postmeta.php'; ?>
    64 <?php the_tags() ?>
    65                     <?php the_content(); ?>                     
    66                     <?php if ($post->comment_status == "open") { ?>
    67                     <?php comments_template('', true); ?>
    68                     <?php } ?>
    69                
    70             </div>
    71         <?php endwhile; else: ?>
    72          
    73        
    74 <?php endif; ?>
     36<p>
     37<table class="table table-striped table-condensed ">
     38              <tbody>
     39                <tr>
     40                  <td>Bathrooms</td>
     41                  <td><?php echo get_post_meta($post->ID,'dfd_BathroomsTotal',true); ?></td>
     42        <td>Bedrooms</td>
     43                  <td><?php echo get_post_meta($post->ID,'dfd_BedroomsTotal',true); ?></td>
     44       
     45                </tr>
     46                <tr>
     47          <td>Property Type</td>
     48                  <td><?php echo get_post_meta($post->ID,'dfd_PropertyType',true); ?></td>
     49                  <td>Built in</td>
     50                  <td><?php echo get_post_meta($post->ID,'dfd_YearBuilt',true); ?></td>
     51                </tr>
     52                <tr>
     53                  <td>LotSize:</td>
     54                  <td><?php echo get_post_meta($post->ID,'dfd_LotSizeArea',true); ?> <?php echo get_post_meta($post->ID,'dfd_LotSizeUnits',true); ?></td>
     55           <td>Building Area</td>
     56                  <td><?php echo get_post_meta($post->ID,'dfd_BuildingAreaTotal',true); ?> <?php echo get_post_meta($post->ID,'dfd_BuildingAreaUnits',true); ?></td>   
     57                </tr>
     58              </tbody></table></p> 
     59
     60<table class="table table-striped table-condensed ">
     61     <caption>Rooms</caption>
     62              <tbody>
     63        <tr>
     64            <th>Level</th>
     65            <th>Type</th>
     66            <th>Dimensions</th>
     67        </tr>
     68        <?php
     69for ($i=1; $i<=20; $i++)
     70  {
     71     echo "<tr data-dp='".'dfd_RoomLevel' . $i . "'>";
     72     echo "<td>" . get_post_meta($post->ID,'dfd_RoomLevel' . $i ,true) . "</td>";   
     73     echo "<td>" . get_post_meta($post->ID,'dfd_RoomType' . $i ,true) . "</td>";
     74     echo "<td>" . get_post_meta($post->ID,'dfd_RoomDimensions' . $i ,true) . "</td>";
     75     echo "</tr>";
     76  }
     77?>
     78              </tbody></table></p>   
     79</div>
     80<div class="span4">
     81<!-- Agent --><h3>Agent Details</h3>
     82<div class="row-fluid">
     83<div class="span6">
     84<address>
     85  <strong><?php echo get_post_meta($post->ID,'dfd_ListAgentFullName',true); ?></strong><br>
     86  <?php echo get_post_meta($post->ID,'dfd_ListAgentDesignation',true); ?><br>
     87
     88  <abbr title="Phone">O:</abbr> <?php echo get_post_meta($post->ID,'dfd_ListAgentOfficePhone',true); ?>
     89  <abbr title="Pager">P:</abbr> <?php echo get_post_meta($post->ID,'dfd_ListAgentPager',true); ?>
     90  <abbr title="Fax">H:</abbr> <?php echo get_post_meta($post->ID,'dfd_ListAgentFax',true); ?>
     91  <abbr title="Web">W:</abbr> <?php echo get_post_meta($post->ID,'dfd_ListAgentURL',true); ?>
     92  <abbr title="Cell">C:</abbr> <?php echo get_post_meta($post->ID,'dfd_ListAgentCellPhone',true); ?>
     93</address>
     94<address>
     95<?php echo get_post_meta($post->ID,'dfd_ListOfficeName',true); ?>
     96<?php echo get_post_meta($post->ID,'dfd_ListOfficePhone',true); ?>
     97<?php echo get_post_meta($post->ID,'dfd_ListOfficeURL',true); ?>
     98</address></div>       
     99<div class="span6">         <!-- Co Agent -->
     100<address>
     101  <strong><?php echo get_post_meta($post->ID,'dfd_CoListAgentFullName',true); ?></strong><br>
     102  <?php echo get_post_meta($post->ID,'dfd_CoListAgentDesignation',true); ?><br>
     103  <abbr title="Phone">O:</abbr> <?php echo get_post_meta($post->ID,'dfd_CoListAgentOfficePhone',true); ?>
     104  <abbr title="Pager">P:</abbr> <?php echo get_post_meta($post->ID,'dfd_CoListAgentPager',true); ?>
     105  <abbr title="Fax">H:</abbr> <?php echo get_post_meta($post->ID,'dfd_CoListAgentFax',true); ?>
     106  <abbr title="Web">W:</abbr> <?php echo get_post_meta($post->ID,'dfd_CoListAgentURL',true); ?>
     107  <abbr title="Cell">C:</abbr> <?php echo get_post_meta($post->ID,'dfd_CoListAgentCellPhone',true); ?>
     108</address>
     109<address>
     110<?php echo get_post_meta($post->ID,'dfd_CoListOfficeName',true); ?>
     111<?php echo get_post_meta($post->ID,'dfd_CoListOfficePhone',true); ?>
     112<?php echo get_post_meta($post->ID,'dfd_CoListOfficeURL',true); ?>
     113</address>
    75114</div>
    76115</div>
     116</div>
     117</div>
     118</div>
     119<!-- empty element for pager links -->
     120<?php //echo get_post_meta($post->ID,'dfd_AnalyticsClick',true); ?>
     121<?php //echo get_post_meta($post->ID,'dfd_AnalyticsView',true); ?>
     122<script src="http://code.jquery.com/jquery.js"></script>
     123<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
     124<script src="http://malsup.github.com/jquery.cycle2.js"></script>
     125
    77126
    78127<?php get_footer(); ?>
     128
     129©1998-2013 The Canadian Real Estate Association. All rights reserved. MLS®, Multiple Listing Service®, and all related graphics are trademarks of The Canadian Real Estate Association. REALTOR®, REALTORS®, and all related graphics are trademarks of REALTOR® Canada Inc. a corporation owned by The Canadian Real Estate Association and the National Association of REALTORS®.
     130©2013 Soldpress Plugin
  • soldpress/branches/0.9.5A/soldpress.php

    r703015 r708983  
    44Plugin URI: http://www.sanskript.com/products/soldpress
    55Description: SoldPress is a WordPress plugin to enable CREA’s members to easily disseminate MLS® listing content on WordPress Sites.
    6 Version: 0.9.5 A
     6Version:  0.9.5 A M1
    77Author: Amer Gill
    88Author URI: http://www.sanskript.com
     
    1010*/
    1111
     12ini_set('max_execution_time', 600);
     13ini_set('mysql.connect_timeout', 600);
     14ini_set('default_socket_timeout', 600);
     15
    1216add_filter( 'query_vars','soldpress_query_vars' );
     17//add_theme_support('post-thumbnails');
    1318
    1419require_once(dirname(__FILE__)."/adapter.php");
     
    2732
    2833function deactivate_cron_hook(){
    29 wp_clear_scheduled_hook('soldpress_listing_sync');
     34    wp_clear_scheduled_hook('soldpress_listing_sync');
     35    wp_clear_scheduled_hook('soldpress_photo_sync');
    3036}
    31 
    32 /*register_deactivation_hook(__FILE__, soldpress_deactivate);
    33 
    34 function soldpress_deactivate()
    35 {
    36     unregister_setting( 'sc-settings-group', 'sc-username' );
    37     unregister_setting( 'sc-settings-group', 'sc-password' );
    38     unregister_setting( 'sc-settings-group', 'sc-url' );
    39     unregister_setting( 'sc-settings-group', 'sc-template' );
    40 }*/
    4137
    4238register_activation_hook(__FILE__, 'soldpress_activation');
    4339
    44 add_action('soldpress_listing_sync', 'soldpress_hourly');
     40add_action('soldpress_listing_sync', 'soldpress_listintgs');
     41add_action('soldpress_photo_sync', 'soldpress_photo');
    4542
    4643function soldpress_activation() {
    4744
    48     //wp_schedule_event( time(), 'daily', 'soldpress_listing_sync');
    49     wp_schedule_event( time(), 'hourly', 'soldpress_listing_sync');
     45    update_option( 'sc-status', '');
     46    update_option( 'sc-sync-start','' );
     47    update_option( 'sc-sync-end','' );
     48   
     49    //Create SoldPress Directory
     50    $wp_upload_dir = wp_upload_dir();
     51    $target = $wp_upload_dir['basedir']. '/soldpress/';
     52    //  if ( wp_mkdir_p( $target ) === TRUE ) //Future Error
     53    wp_mkdir_p( $target );
     54   
     55    //Schedule The Events
     56    wp_schedule_event( time(), 'daily', 'soldpress_listing_sync');
     57    wp_schedule_event( time(), 'hourly', 'soldpress_photo_sync');
    5058}
    5159
    52 function soldpress_hourly() {
    53     // do something every hour
    54     update_option( 'sc-lastupdate', time() );
     60function soldpress_listintgs() {       
     61
     62    date_default_timezone_set('UTC');
     63    $lastupdate = get_option('sc-lastupdate');
    5564   
     65    if(!$lastupdate){
     66        //Sync Last 90 days
     67        $days = 90;
     68        $date = new DateTime();
     69        $date->sub(new DateInterval('P' . $days . 'D'));   
     70        update_option( 'sc-lastupdate', new DateTime());
     71    }else
     72    {
     73        $date = $lastupdate ;
     74        $date->add(new DateInterval('P' . 1 . 'D'));
     75        update_option( 'sc-lastupdate', $date);
     76    }
     77
     78    //Do a future check/ if the date time is before now don't do any thing the usemay have reactivate the plugin.
     79    $adapter= new soldpress_adapter();
     80   
     81    if($adapter->connect())
     82    {
     83        return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z",""); 
     84        //return $adapter-> sync_residentialproperty("LastUpdated=" . $date->format('Y-m-d'),"");   
     85    }
     86   
     87
     88}
     89
     90function soldpress_photo() {
     91    echo 'soldpress_photo';
    5692    $adapter= new soldpress_adapter();
    5793    if($adapter->connect())
    5894    {
    59         return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z","");  //HardCode Time For Testing
     95        return $adapter-> sync_pictures(); 
    6096    }
    61 
    6297}
    6398
     
    65100
    66101function include_template_function( $template_path ) {
     102
     103//Thanks Brother : http://wp.tutsplus.com/tutorials/plugins/a-guide-to-wordpress-custom-post-types-taxonomies-admin-columns-filters-and-archives/
    67104    if ( get_post_type() == 'property' ) {
    68105        if ( is_single() ) {
     
    75112            }
    76113        }
     114    elseif ( is_archive() ) {
     115            if ( $theme_file = locate_template( array ( 'archive-property.php' ) ) ) {
     116                $template_path = $theme_file;
     117            } else { $template_path = plugin_dir_path( __FILE__ ) . '/archive-property.php';
     118 
     119            }
     120        }
    77121    }
    78122    return $template_path;
  • soldpress/branches/0.9.5A/template/template.html

    r693468 r708983  
    1 <h1>&#36;{$rets['ListPrice']}</h1>
     1<h1>&#36;{$rets['ListPrice']}</h1>
    22<h3>{$rets['UnparsedAddress']}, {$rets['City']}</h3>
    33{$rets['BedroomsTotal']} Bedrooms | {$rets['BathroomsTotal']} Bathrooms | {$rets['LotSizeArea']} {$rets['LotSizeUnits']}.
Note: See TracChangeset for help on using the changeset viewer.