Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @file
- * Default simple view template to display a list of rows.
- *
- * @ingroup views_templates
- */
- ?>
- <?php if (!empty($title)): ?>
- <h3><?php print $title; ?></h3>
- <?php endif; ?>
- <?php
- global $user;
- $country = "";
- if($user->uid!=1 && $user->uid!=0){
- $user_full = profile2_by_uid_load($user->uid);
- if(!empty($user_full['client'])){
- $country_parent = taxonomy_get_parents($user_full['client']->field_clcountry['und'][0]['tid']);
- foreach($country_parent as $key=>$country_parent_value){
- $country_name = $country_parent_value->name;
- }
- if(isset($country_name)){
- $country = $country_name;
- }
- else{
- $country_full =taxonomy_term_load($user_full['client']->field_clcountry['und'][0]['tid']);
- $country = $country_full->name;
- }
- $t = taxonomy_get_term_by_name($country, $vocabulary = "country_action");
- $tid = array(1510,2160);
- foreach($t as $key=>$value){
- $tid[] = $key;
- $child = taxonomy_get_children($key);
- foreach($child as $key_tid =>$child_value){
- $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
- if(isset($tax_node[0])){
- $tid[] = $key_tid;
- }
- }
- }
- $tid_for_js = json_encode($tid);
- drupal_add_js('jQuery(document).ready(function () {
- var tid = '.$tid_for_js.';
- if ($("#views-exposed-form-rf-page").length > 0){
- var filter = $("#views-exposed-form-rf-page select option");
- }
- else if ($("#views-exposed-form-rf-page-1").length > 0){
- var filter = $("#views-exposed-form-rf-page-1 select option");
- }
- var count = 0;
- for (var i=0; i < filter.length; i++) {
- if (filter[i].selected){ count++};
- }
- if(filter.length==count || count==0){
- var isChromium = window.chrome,
- vendorName = window.navigator.vendor;
- if(isChromium !== null && vendorName === "Google Inc.") {
- filter.each(function(){
- $(this).removeAttr("selected");
- option_tid = $(this).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- $(this).attr("selected","selected");
- }
- });
- } else {
- for (var i=0; i < filter.length; i++) {
- filter[i].removeAttribute("selected");
- option_tid = $(filter[i]).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- filter[i].setAttribute("selected","selected");
- }
- }
- }
- $("#edit-submit-rf").click();
- }
- });', 'inline');
- }
- }
- elseif($user->uid==0){
- $ip = ip_address();
- $country_code = ip2country_get_country($ip);
- $country_list = country_get_list();
- $country = $country_list[$country_code];
- $sid = session_api_get_sid();
- $session_country = db_query("SELECT country FROM {session_api} WHERE sid = :sid", array(':sid' => $sid))->fetchField();
- if(empty($session_country)){
- if(isset($_POST['country'])){
- db_update('session_api')->fields(array('country' => $_POST['country']))->condition('sid', $sid)->execute();
- $t = taxonomy_get_term_by_name($_POST['country'], $vocabulary = "country_action");
- $tid = array(1510,2160);
- foreach($t as $key=>$value){
- $tid[] = $key;
- $child = taxonomy_get_children($key);
- foreach($child as $key_tid =>$child_value){
- $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
- if(isset($tax_node[0])){
- $tid[] = $key_tid;
- }
- }
- }
- $tid_for_js = json_encode($tid);
- drupal_add_js('jQuery(document).ready(function () {
- var tid = '.$tid_for_js.';
- if ($("#views-exposed-form-rf-page").length > 0){
- var filter = $("#views-exposed-form-rf-page select option");
- }
- else if ($("#views-exposed-form-rf-page-1").length > 0){
- var filter = $("#views-exposed-form-rf-page-1 select option");
- }
- var count = 0;
- for (var i=0; i < filter.length; i++) {
- if (filter[i].selected){ count++};
- }
- if(filter.length==count || count==0){
- var isChromium = window.chrome,
- vendorName = window.navigator.vendor;
- if(isChromium !== null && vendorName === "Google Inc.") {
- filter.each(function(){
- $(this).removeAttr("selected");
- option_tid = $(this).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- $(this).attr("selected","selected");
- }
- });
- } else {
- for (var i=0; i < filter.length; i++) {
- filter[i].removeAttribute("selected");
- option_tid = $(filter[i]).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- filter[i].setAttribute("selected","selected");
- }
- }
- }
- $("#edit-submit-rf").click();
- $("#block-views-country-anonym-block").css("display","none");
- }
- });', 'inline');
- }
- else{
- drupal_add_js('jQuery(document).ready(function () {
- $("#block-views-country-anonym-block").css("display","block");
- });', 'inline');
- }
- }
- else{
- $t = taxonomy_get_term_by_name($session_country, $vocabulary = "country_action");
- $tid = array(1510,2160);
- foreach($t as $key=>$value){
- $tid[] = $key;
- $child = taxonomy_get_children($key);
- foreach($child as $key_tid =>$child_value){
- $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
- if(isset($tax_node[0])){
- $tid[] = $key_tid;
- }
- }
- }
- $tid_for_js = json_encode($tid);
- drupal_add_js('jQuery(document).ready(function () {
- var tid = '.$tid_for_js.';
- if ($("#views-exposed-form-rf-page").length > 0){
- var filter = $("#views-exposed-form-rf-page select option");
- }
- else if ($("#views-exposed-form-rf-page-1").length > 0){
- var filter = $("#views-exposed-form-rf-page-1 select option");
- }
- var count = 0;
- for (var i=0; i < filter.length; i++) {
- if (filter[i].selected){ count++};
- }
- if(filter.length==count || count==0){
- var isChromium = window.chrome,
- vendorName = window.navigator.vendor;
- if(isChromium !== null && vendorName === "Google Inc.") {
- filter.each(function(){
- $(this).removeAttr("selected");
- option_tid = $(this).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- $(this).attr("selected","selected");
- }
- });
- } else {
- for (var i=0; i < filter.length; i++) {
- filter[i].removeAttribute("selected");
- option_tid = $(filter[i]).val();
- if($.inArray(parseInt(option_tid), tid)> -1){
- filter[i].setAttribute("selected","selected");
- }
- }
- }
- $("#edit-submit-rf").click();
- }
- });', 'inline');
- }
- }
- ?>
- <?php foreach ($rows as $id => $row): ?>
- <div <?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"'; } ?>>
- <?php print $row; ?>
- </div>
- <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement