}
}
if (!is_null($message)) {
    ?>
	<div class="updated">
		<p>
			<strong>
				<?php 
    echo $message;
    ?>
			</strong>
		</p>
	</div>
	<?php 
}
$attributes = Idp_Main::getAttributes();
foreach ($attributes as $attribute) {
    if ($attribute->id == $attribute_id) {
        $attribute_name = $attribute->attribute;
    }
}
?>


<div class="wrap">
    <h1>
    	<?php 
echo __('Manage Attribute Values', 'idp-plugin');
?>
    	<small>(<?php 
echo $attribute_name;
Пример #2
0
function showSearchForm($filterAttributes)
{
    //filterAttributes must have the following form:
    //example: $filterAttributes['1'] = [4, ['München']]
    //where '1' = ID of the filter (values 1-4), 4 = attribute-ID, ['München'] = List of selectable values
    $districts = Idp_Main::getAllDistricts();
    $selectedDistrict = -1;
    if (key_exists('district', $filterAttributes)) {
        $selectedDistrict = $filterAttributes['district'];
    }
    $keywords = "";
    if (key_exists('keywords', $filterAttributes)) {
        $keywords = $filterAttributes['keywords'];
    }
    $image_category = 0;
    if (key_exists('image_category', $filterAttributes)) {
        $image_category = $filterAttributes['image_category'];
    }
    $image_tags = [];
    if (key_exists('image_tags', $filterAttributes)) {
        $image_tags = Idp_Main::getImageTagsByIds($filterAttributes['image_tags']);
    }
    $favorites_of = -1;
    if (key_exists('favorites_of', $filterAttributes)) {
        $favorites_of = $filterAttributes['favorites_of'];
    }
    ?>
	<div id="searchForm">
		<form method="post" action=".">
			<h6><?php 
    echo __('Search for building attributes', 'idp-theme');
    ?>
</h6>
			<div class="row">
				<div class="col-md-6">
					<select id="district" name = "district" class="form-control input-sm">
						<option value="-1"><?php 
    echo __('All districts', 'idp-theme');
    ?>
</option>
						<?php 
    foreach ($districts as $district) {
        echo "<option ";
        if ($district['district_id'] == $selectedDistrict) {
            echo " selected ";
        }
        echo "value=\"{$district['district_id']}\">{$district['district_name']}</option>";
    }
    ?>
					</select>
				</div>
				<div class="col-md-6">
					<div class="input-group input-group-sm" style="width: 100%">
						<input id="keywords" name="keywords" type="text" value="<?php 
    echo $keywords;
    ?>
" class="form-control" placeholder="<?php 
    echo __('Keywords', 'idp-theme');
    ?>
...">
						<span class="input-group-btn">
							<button id="clearKeywordsButton" class="btn btn-default" type="button"><span class="glyphicon glyphicon-remove"></span></button>
						</span>
					</div>
				</div>
			</div>
			<br/>
			<script>
				$("#clearKeywordsButton").on("click", function(){
				$("#keywords").val('');			
				}).change();
			</script>
		
		
			<div class="row">
				<?php 
    $categories = Idp_Main::getAttributeCategories();
    for ($i = 1; $i <= 3; $i++) {
        ?>
					<div class="col-md-3">
						<div class="input-group input-group-sm" style="width: 100%">
							<select id="filter<?php 
        echo $i;
        ?>
" name="filter<?php 
        echo $i;
        ?>
" class="form-control">
								<option value = "-1" label="<?php 
        echo __('Choose attribute', 'idp-theme');
        ?>
...."><?php 
        echo __('Choose attribute', 'idp-theme');
        ?>
...</option>
								<?php 
        foreach ($categories as $category) {
            $attributes = Idp_Main::getAttributes($category->id);
            echo "<optgroup label=\"{$category->name}\">";
            foreach ($attributes as $attribute) {
                $selectableValues = Idp_Main::getAllSetValuesForAttribute($attribute->id);
                if (!empty($selectableValues) and $attribute->visible != 0) {
                    echo "<option ";
                    if (array_key_exists($i, $filterAttributes)) {
                        if ($attribute->id == $filterAttributes[$i][0]) {
                            echo " selected ";
                        } else {
                            for ($j = 1; $j <= 3; $j++) {
                                if ($i != $j and $attribute->id == $filterAttributes[$j][0]) {
                                    echo " disabled ";
                                }
                            }
                        }
                    }
                    echo "value = \"{$attribute->id}\" label=\"{$attribute->attribute}\">{$attribute->attribute}</option>";
                }
            }
            echo "</optgroup>";
        }
        ?>
							</select>	
							<span class="input-group-btn">
								<button id="clearFilter<?php 
        echo $i;
        ?>
" class="btn btn-default" type="button"><span class="glyphicon glyphicon-remove"></span></button>
							</span>							
						</div>
						
						<script>
						$("#clearFilter<?php 
        echo $i;
        ?>
").on("click", function(){
						$("#filter<?php 
        echo $i;
        ?>
").val(-1);	
						$("#filter<?php 
        echo $i;
        ?>
").trigger("change");
						});
						</script>
						
						<?php 
        $searchAttribute = -1;
        $selectedValues = [];
        if (array_key_exists($i, $filterAttributes)) {
            $searchAttribute = $filterAttributes[$i][0];
            $selectedValues = $filterAttributes[$i][1];
        }
        ?>
				
						<div id="valueSelect<?php 
        echo $i;
        ?>
">
							<?php 
        getSearchableValues($i, $searchAttribute, $selectedValues, false);
        ?>
						</div>
						<script>
							$("#filter<?php 
        echo $i;
        ?>
").on("change", function(){
										var ajaxurl = '<?php 
        echo admin_url('admin-ajax.php');
        ?>
';
										var data = {'action': 'getSearchableValues', 'index': <?php 
        echo $i;
        ?>
, 'searchAttribute': $(this).val(), 'selectedValues': <?php 
        echo json_encode($selectedValues);
        ?>
};
										jQuery.post(ajaxurl, data, function(response) {
											$('#valueSelect<?php 
        echo $i;
        ?>
').html(response);
										});	
							});
						</script>
					</div>
				<?php 
    }
    ?>
				
				<div class="col-md-3">
					<div class="input-group" style="width: 100%">
						<input id="decade" name="decade" type="checkbox" <?php 
    key_exists('decade', $filterAttributes) ? print 'checked' : (print '');
    ?>
 >
						<label for="decade"><?php 
    echo __('Built in decades', 'idp-theme');
    ?>
</label>
					</div>
					<div class="row">
						<div class="col-md-5">
							<?php 
    $decades = Idp_Main::getAllDecades();
    ?>
							<select id="decadeFrom" name="decadeFrom" class="form-control input-sm">
								<?php 
    if (key_exists('decadeFrom', $filterAttributes)) {
        $decadeFrom = $filterAttributes['decadeFrom'];
    } else {
        $decadeFrom = $decades[0]->decade;
    }
    foreach ($decades as $decade) {
        echo "<option ";
        if ($decade->decade == $decadeFrom) {
            echo "selected ";
        }
        echo "value=\"{$decade->decade}\" label=\"{$decade->decade}er\">{$decade->decade}er</option>";
    }
    ?>
							</select>
							</div>
							<div class="col-md-2">
							<?php 
    echo __('to', 'idp-theme');
    ?>
							</div>
							<div class="col-md-5">
							<select id="decadeTo" name="decadeTo" class="form-control input-sm">
								<?php 
    if (key_exists('decadeTo', $filterAttributes)) {
        $decadeTo = $filterAttributes['decadeTo'];
    } else {
        $decadeTo = end($decades)->decade;
    }
    foreach ($decades as $decade) {
        echo "<option ";
        if ($decade->decade == $decadeTo) {
            echo "selected ";
        }
        echo "value=\"{$decade->decade}\" label=\"{$decade->decade}er\">{$decade->decade}er</option>";
    }
    ?>
							</select>
						</div>
					</div>
				</div>
					
				<script>
					$('#decade').on("change", function(){
						if($(this).prop('checked')){
							$('#decadeFrom').prop("disabled", false);
							$('#decadeTo').prop("disabled", false);
						}
						else{
							$('#decadeFrom').prop("disabled", true);
							$('#decadeTo').prop("disabled", true);
						}
					}).change();
				</script>
					
			</div>

			<h6><?php 
    echo __('Image Search', 'idp-theme');
    ?>
</h6>
			<div class="row">
				<div class="col-md-6">
					<select name="image_category" id="image_category" class="form-control input-sm">
						<option value="0"><?php 
    echo __('All image categories', 'idp-theme');
    ?>
</option>
						<?php 
    $categories = Idp_Main::getImageCategories();
    foreach ($categories as $category) {
        $selected = "";
        if (!empty($image_category) && $category->id == $image_category) {
            $selected = "selected";
        }
        echo "<option {$selected} value=\"{$category->id}\">{$category->name}</option>";
    }
    ?>
					</select>
				</div>
				<div class="col-md-6">
				<div class="input-group input-group-sm">
					<span class="input-group-addon">
					<span class="glyphicon glyphicon-tags" aria-hidden="true" title="Nach Tags suchen"></span></span>
					<input name="image_tags" id="image_tags" type="text" class="form-control"/>
					</div>
					<a data-toggle="modal" href="#imageTagsModal"><?php 
    _e('Show all tags', 'idp-theme');
    ?>
</a>
				</div>
			</div>
			<br/>
			
			<script>			
			$('select[id^="filter"]').on("change", function() {
				var selectedValues = [];
				var sel = $('select[id^="filter"]');
				sel.each(function() {
					selectedValues.push(this.value);
				});
				sel.find('option').prop('disabled', false);
				sel.each(function() {
					if(jQuery.inArray( this.value, selectedValues ) > -1){
						sel.not(this).find('option[value=' + this.value + '][value!=-1]').prop('disabled', true);
					}
				});				
			});
			</script>
			<script>
				$(function(){
					<?php 
    foreach ($image_tags as $image_tag) {
        echo "\$('#image_tags').tagsinput('add', { value: {$image_tag->id}, text: '{$image_tag->name}' });";
    }
    ?>
				});
			</script>
			
			<?php 
    $usersWithFavorites = Idp_Main::getUsersWithFavorites();
    ?>
			<div class="row">
			<div class="col-md-6">
			<div class="input-group">
			  <span class="input-group-btn">
				<button class="btn btn-primary" type="submit"><?php 
    echo __('Search', 'idp-theme');
    ?>
</button>
			  </span>
			  <select name="favorites_of" id="favorites_of" class="form-control">
					<option value="-1"><?php 
    echo __('in all buildings', 'idp-theme');
    ?>
</option>
					<?php 
    foreach ($usersWithFavorites as $user_id => $user_name) {
        echo "<option ";
        if ($user_id == $favorites_of) {
            echo " selected ";
        }
        echo "value=\"{$user_id}\">" . __('in favorites of', 'idp-theme') . " {$user_name}</option>";
    }
    ?>
			  </select>
			</div>
			</div>
			</div>
		</form>
	</div>
	<br/>
	<?php 
}
		    <tbody class="searchable">
		    <?php 
$categories = Idp_Main::getAttributeCategories();
$row_alternate = true;
foreach ($categories as $category) {
    if ($row_alternate) {
        ?>
		    			<tr class=\"alternate\" valign=\"top\">
		    			<?php 
    } else {
        ?>
		    			<tr valign=\"top\">
		    			<?php 
    }
    if (count(Idp_Main::getAttributes($category->id)) > 0) {
        //Attributes exist for this category. Should have no possibility to delete this category
        $disabled = " disabled=\"disabled\" title=\"" . __('Attributes exist for this category. Move them to another category in order to delete.', 'idp-plugin') . "\" ";
    } else {
        $disabled = "";
    }
    ?>
			    		<th class="check-column" scope="row">
				        	<label class="screen-reader-text" for="cb-select-<?php 
    echo $category->id;
    ?>
"><?php 
    echo __('Choose Category', 'idp-plugin');
    ?>
</label>
							<input id="cb-select-<?php 
										</div>
									</div>
								</div>

							<?php 
                $search = [' ', '(', ')'];
                foreach ($categories as $category) {
                    echo "<div class=\"panel panel-default\">";
                    echo "<div class=\"panel-heading\">";
                    echo "<h4 class=\"panel-title\">";
                    echo "<a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#" . str_replace($search, '', $category->name) . "\">" . $category->name . "</a>";
                    echo "</h4>";
                    echo "</div>";
                    echo "<div id=\"" . str_replace($search, '', $category->name) . "\" class=\"panel-collapse collapse\">";
                    echo "<div class=\"panel-body\">";
                    $attributes = Idp_Main::getAttributes($category->id);
                    $attribute_count = count($attributes);
                    $row_counter = 1;
                    echo "<div class=\"col-md-12\">";
                    //
                    foreach ($attributes as $attribute) {
                        if ($row_counter % 2 != 0) {
                            echo "<div class=\"row\">";
                        }
                        echo "<div class=\"col-md-6\">";
                        echo "<div class=\"form-group\" id=\"form-" . str_replace(' ', '', $attribute->attribute) . "\">";
                        if (trim($attribute->description) != '') {
                            $tooltip = "<span data-toggle=\"tooltip\" title=\"{$attribute->description}\" class=\"glyphicon glyphicon-info-sign\"></span>";
                        } else {
                            $tooltip = "";
                        }
?>
</th>
		    		<th class="manage-column column-col_attribute_description" scope="col"><?php 
echo __('Description', 'idp-plugin');
?>
</th>
					<th class="manage-column column-col_attribute_ranking" scope="col"><?php 
echo __('Ranking', 'idp-plugin');
?>
</th>
		        </tr>
		    </tfoot>

		    <tbody class="searchable">
		    <?php 
$attributes = Idp_Main::getAttributes($category_id_filter);
$row_alternate = true;
foreach ($attributes as $attribute) {
    if ($row_alternate) {
        ?>
		    			<tr class=\"alternate\" valign=\"top\">
		    			<?php 
    } else {
        ?>
		    			<tr valign=\"top\">
		    			<?php 
    }
    if (count(Idp_Main::getAllSetValuesForAttribute($attribute->id)) > 0) {
        //there are published buildings with values set for this attribute. Don't allow to delete it
        $disabled = " disabled=\"disabled\" title=\"" . __('There are published buildings with values set for this attribute. Thus, it is not possible to delete this attribute. Please hide it instead.', 'idp-plugin') . "\"";
    } else {