예제 #1
0
 public function testNotContainedInQueries()
 {
     Helper::clearClass("BoxedNumber");
     $this->saveObjects(10, function ($i) {
         $boxedNumber = ParseObject::create("BoxedNumber");
         $boxedNumber->set("number", $i);
         return $boxedNumber;
     });
     $query = new ParseQuery("BoxedNumber");
     $query->notContainedIn("number", [3, 5, 7, 9, 11]);
     $results = $query->find();
     $this->assertEquals(6, count($results), 'Did not return correct number of objects.');
 }
        private function results()
        {
            global $wp_query, $post, $wtd_plugin, $wtd_connector;
            $res_id = get_post_meta($post->ID, 'res_id', true);
            $parent_cat_id = get_query_var('wtdc');
            $cat_id = get_query_var('wtds');
            $excluded_cats = json_decode(get_option('wtd_excluded_cats'));
            if (empty($cat_id) & isset($_GET['wtds'])) {
                $cat_id = $_GET['wtds'];
            }
            // get parent category
            $query = new ParseQuery('resortParentCategories');
            $parent_cat = $query->get($parent_cat_id);
            // get category if its set
            if (!empty($cat_id)) {
                $query = new ParseQuery('resortCategory');
                $cat = $query->get($cat_id);
            }
            // parent restriction query
            $parent_cat_query = new ParseQuery('resortParentCategories');
            $parent_cat_query->equalTo('objectId', $parent_cat_id);
            // subcategory query
            $query = new ParseQuery('resortCategory');
            $query->matchesQuery('parentResCatObjectId', $parent_cat_query);
            $query->equalTo('deleted', false);
            $query->greaterThan('activityCnt', 0);
            if (!empty($excluded_cats)) {
                $query->notContainedIn('objectId', $excluded_cats);
            }
            $query->ascending('name');
            try {
                $categories = $query->find();
            } catch (\Parse\ParseException $ex) {
                var_dump($ex);
            }
            ?>
            <link rel="stylesheet" href="<?php 
            echo WTD_PLUGIN_URL . 'assets/css/wtd_activities_page.css?wtd_version=' . WTD_VERSION;
            ?>
" media="screen"/>
	        <div ng-app="activitiesApp" ng-controller="activitiesCtrl">
	            <div layout="row" layout-padding><?php 
            if ($wtd_plugin['act_page_type'] == 3) {
                ?>
	                    <ul layout="column"><?php 
                for ($i = 0; $i < count($categories); $i++) {
                    $category = $categories[$i];
                    $category_url_name = strtolower($parent_cat->get('name'));
                    $category_url_name = str_replace(' ', '-', $category_url_name);
                    $category_url_name = str_replace('/', '-', $category_url_name);
                    $subcategory_url_name = strtolower($category->get('name'));
                    $subcategory_url_name = str_replace(' ', '-', $subcategory_url_name);
                    $subcategory_url_name = str_replace(',', '', $subcategory_url_name);
                    $subcategory_url_name = str_replace('/', '-', $subcategory_url_name);
                    $url = site_url() . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/' . $subcategory_url_name . '/' . $category->getObjectId() . '/';
                    ?>
		                        <li class="wtd_subcategory_menu_item <?php 
                    echo $category->getObjectId() == $wp_query->query['wtds'] ? 'active' : '';
                    ?>
">
		                            <a href="<?php 
                    echo $url;
                    ?>
"><?php 
                    echo $category->get('name');
                    ?>
</a>
		                        </li><?php 
                }
                ?>
	                    </ul><?php 
            }
            if ($wtd_plugin['act_page_type'] == 2) {
                $column_size = 100;
            } else {
                $column_size = 75;
            }
            ?>
	                <div layout="row" layout-align="center start" ng-hide="progress == false" layout-padding flex="100">
		                <md-progress-circular class="md-primary" md-mode="indeterminate"></md-progress-circular>
	                </div>
	                <div layout="column" flex="<?php 
            echo $column_size;
            ?>
" flex-sm="100" ng-hide="progress == true">
	                    <div layout="row" style="margin-bottom: 5px;">
		                    <a id="parent_<?php 
            echo $post->ID;
            ?>
_header" href="<?php 
            echo get_post_permalink($post->ID);
            ?>
" class="wtd_pull_left"><?php 
            echo $post->post_title;
            ?>
		                    </a><?php 
            if (!empty($parent_cat_id)) {
                $category_url_name = strtolower($parent_cat->get('name'));
                $category_url_name = str_replace(' ', '-', $category_url_name);
                //http://realty.home/vail-valley-activities/whattodo/spa-&-fitness/ZUNm0C89zy/fitness-centers/QoljJWroB8/
                $url = site_url() . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/';
                ?>
			                    <span class="wtd_bread_separator">&gt;</span>
			                    <a id="parent_<?php 
                echo $parent_cat->getObjectId();
                ?>
_header" class="wtd_pull_left" href="<?php 
                echo $url;
                ?>
"><?php 
                echo $parent_cat->get('name');
                ?>
			                    </a><?php 
            }
            if ($wtd_plugin['act_page_type'] == 2) {
                ?>
		                        <span class="wtd_bread_separator">&gt;</span>
		                        <select class="wtd_subcategory_navigator">
			                        <option>Select Subcategory</option><?php 
                for ($i = 0; $i < count($categories); $i++) {
                    $category = $categories[$i];
                    $selected = '';
                    if ($cat_id == $category->getObjectId()) {
                        $selected = ' selected="selected"';
                    }
                    $category_url_name = strtolower($parent_cat->get('name'));
                    $category_url_name = str_replace(' ', '-', $category_url_name);
                    $category_url_name = str_replace('/', '-', $category_url_name);
                    $subcategory_url_name = strtolower($category->get('name'));
                    $subcategory_url_name = str_replace(' ', '-', $subcategory_url_name);
                    $subcategory_url_name = str_replace(',', '', $subcategory_url_name);
                    $subcategory_url_name = str_replace('/', '-', $subcategory_url_name);
                    $url = site_url() . '/' . $post->post_name . '/whattodo/' . $category_url_name . '/' . $parent_cat->getObjectId() . '/' . $subcategory_url_name . '/' . $category->getObjectId() . '/';
                    echo '<option value="' . $url . '" ' . $selected . '>' . $category->get('name') . '</option>';
                }
                ?>
		                        </select><?php 
            } elseif (!empty($cat_id)) {
                ?>
			                    <span class="wtd_bread_separator">&gt;</span>
			                    <span class="wtd_current_cat"><?php 
                echo $cat->name;
                ?>
</span><?php 
            }
            ?>
	                    </div>
	                    <script>
	                        jQuery('.wtd_subcategory_navigator').change(function(){
	                            var val = jQuery('.wtd_subcategory_navigator option:selected').val();
	                            if(val)
	                                window.location = val;
	                        });
	                    </script>
	                    <div id="wtd_listing_sc_container" layout="column" layout-align="start start"></div>
	                </div>
	            </div>
            </div><?php 
            $wtd_base_request = $wtd_connector->get_base_request();
            $wtd_base_request['resorts'] = array($res_id);
            $wtd_base_request['page'] = 1;
            $cat_id = $wp_query->query['wtdc'];
            if (empty($cat_id) && isset($_GET['wtdc'])) {
                $cat_id = $_GET['wtdc'];
            }
            if (isset($wp_query->query['wtds'])) {
                $subcat_id = $wp_query->query['wtds'];
            } else {
                $subcat_id = NULL;
            }
            if (empty($subcat_id) && isset($_GET['wtds'])) {
                $subcat_id = $_GET['wtds'];
            }
            $wtd_base_request['category_id'] = $cat_id;
            if (!empty($subcat_id)) {
                $wtd_base_request['category_id'] = $subcat_id;
            }
            $wtd_excluded_cats = get_option('wtd_excluded_cats');
            if (!empty($wtd_excluded_cats)) {
                $wtd_base_request['excluded_categories'] = json_decode($wtd_excluded_cats);
            }
            ?>
            <script src="<?php 
            echo WTD_PLUGIN_URL;
            ?>
/assets/js/parse-1.6.14.js"></script>
            <script src="<?php 
            echo WTD_PLUGIN_URL;
            ?>
/assets/js/parse_init.js"></script>
            <script>
                var wtd_categories = <?php 
            echo json_encode($this->wtd_categories);
            ?>
;
                var wtd_base_request = <?php 
            echo json_encode($wtd_base_request);
            ?>
;
                var cat_id = '<?php 
            echo $cat_id;
            ?>
';
                var subcat_id = '<?php 
            echo $subcat_id;
            ?>
';
                var wtd_parse_page = 1;
                var cur_category = '<?php 
            echo $cat_id;
            ?>
';
            </script>
	        <script src="<?php 
            echo WTD_PLUGIN_URL;
            ?>
assets/js/pages/activities.js"></script><?php 
            wtd_copyright();
        }