Advertisement
Guest User

Untitled

a guest
Feb 18th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.12 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @file
  5.  * Default simple view template to display a list of rows.
  6.  *
  7.  * @ingroup views_templates
  8.  */
  9. ?>
  10. <?php if (!empty($title)): ?>
  11.   <h3><?php print $title; ?></h3>
  12.  
  13. <?php endif; ?>
  14.       <?php
  15.     global $user;
  16.     $country = "";
  17.        if($user->uid!=1 && $user->uid!=0){
  18.     $user_full = profile2_by_uid_load($user->uid);
  19.         if(!empty($user_full['client'])){
  20.         $country_parent = taxonomy_get_parents($user_full['client']->field_clcountry['und'][0]['tid']);
  21.             foreach($country_parent as $key=>$country_parent_value){
  22.             $country_name = $country_parent_value->name;
  23.             }
  24.             if(isset($country_name)){
  25.             $country = $country_name;
  26.             }
  27.             else{
  28.             $country_full =taxonomy_term_load($user_full['client']->field_clcountry['und'][0]['tid']);
  29.             $country = $country_full->name;
  30.             }
  31.             $t = taxonomy_get_term_by_name($country, $vocabulary = "country_action");
  32.               $tid = array(1510,2160);
  33.               foreach($t as $key=>$value){
  34.               $tid[] = $key;
  35.               $child = taxonomy_get_children($key);
  36.                   foreach($child as $key_tid =>$child_value){
  37.                     $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
  38.                     if(isset($tax_node[0])){
  39.                         $tid[] = $key_tid;
  40.                     }
  41.                   }
  42.             }
  43.             $tid_for_js = json_encode($tid);
  44.                       drupal_add_js('jQuery(document).ready(function () {
  45.                var tid = '.$tid_for_js.';
  46.                if ($("#views-exposed-form-rf-page").length > 0){
  47.                    var filter = $("#views-exposed-form-rf-page select option");
  48.                 }
  49.                 else if ($("#views-exposed-form-rf-page-1").length > 0){
  50.                    var filter = $("#views-exposed-form-rf-page-1 select option");
  51.                 }
  52.              
  53.                var count = 0;
  54.                for (var i=0; i < filter.length; i++) {
  55.                      if (filter[i].selected){ count++};
  56.                }
  57.                
  58.                if(filter.length==count || count==0){
  59.                
  60.                var isChromium = window.chrome,
  61.                    vendorName = window.navigator.vendor;
  62.                if(isChromium !== null && vendorName === "Google Inc.") {
  63.                   filter.each(function(){
  64.                        $(this).removeAttr("selected");
  65.                        option_tid = $(this).val();
  66.                        if($.inArray(parseInt(option_tid), tid)> -1){
  67.                            $(this).attr("selected","selected");
  68.                        }
  69.                    });
  70.                } else {
  71.                   for (var i=0; i < filter.length; i++) {
  72.                      filter[i].removeAttribute("selected");
  73.                      option_tid = $(filter[i]).val();
  74.                        if($.inArray(parseInt(option_tid), tid)> -1){
  75.                            filter[i].setAttribute("selected","selected");
  76.                        }
  77.                    }
  78.                }
  79.  
  80.                    $("#edit-submit-rf").click();
  81.                    
  82.                }
  83.            });', 'inline');
  84.         }
  85.     }
  86.     elseif($user->uid==0){
  87.         $ip = ip_address();
  88.         $country_code = ip2country_get_country($ip);
  89.         $country_list = country_get_list();
  90.         $country = $country_list[$country_code];
  91.         $sid = session_api_get_sid();
  92.         $session_country = db_query("SELECT country FROM {session_api} WHERE sid = :sid", array(':sid' => $sid))->fetchField();
  93.         if(empty($session_country)){
  94.             if(isset($_POST['country'])){
  95.                 db_update('session_api')->fields(array('country' => $_POST['country']))->condition('sid', $sid)->execute();
  96.                 $t = taxonomy_get_term_by_name($_POST['country'], $vocabulary = "country_action");
  97.                 $tid = array(1510,2160);
  98.                 foreach($t as $key=>$value){
  99.                 $tid[] = $key;
  100.                 $child = taxonomy_get_children($key);
  101.                     foreach($child as $key_tid =>$child_value){
  102.                        $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
  103.                         if(isset($tax_node[0])){
  104.                             $tid[] = $key_tid;
  105.                         }
  106.                     }
  107.                 }
  108.                 $tid_for_js = json_encode($tid);
  109.                 drupal_add_js('jQuery(document).ready(function () {
  110.                    var tid = '.$tid_for_js.';
  111.                if ($("#views-exposed-form-rf-page").length > 0){
  112.                    var filter = $("#views-exposed-form-rf-page select option");
  113.                 }
  114.                else if ($("#views-exposed-form-rf-page-1").length > 0){
  115.                    var filter = $("#views-exposed-form-rf-page-1 select option");
  116.                 }
  117.                var count = 0;
  118.                for (var i=0; i < filter.length; i++) {
  119.                      if (filter[i].selected){ count++};
  120.                }
  121.                
  122.                if(filter.length==count || count==0){
  123.                
  124.                var isChromium = window.chrome,
  125.                    vendorName = window.navigator.vendor;
  126.                if(isChromium !== null && vendorName === "Google Inc.") {
  127.                   filter.each(function(){
  128.                        $(this).removeAttr("selected");
  129.                        option_tid = $(this).val();
  130.                        if($.inArray(parseInt(option_tid), tid)> -1){
  131.                            $(this).attr("selected","selected");
  132.                        }
  133.                    });
  134.                } else {
  135.                   for (var i=0; i < filter.length; i++) {
  136.                      filter[i].removeAttribute("selected");
  137.                      option_tid = $(filter[i]).val();
  138.                        if($.inArray(parseInt(option_tid), tid)> -1){
  139.                            filter[i].setAttribute("selected","selected");
  140.                        }
  141.                    }
  142.                }
  143.                    
  144.                    $("#edit-submit-rf").click();
  145.                    $("#block-views-country-anonym-block").css("display","none");
  146.                }
  147.                });', 'inline');
  148.             }
  149.             else{
  150.                 drupal_add_js('jQuery(document).ready(function () {
  151.                    $("#block-views-country-anonym-block").css("display","block");
  152.                });', 'inline');
  153.             }          
  154.            }
  155.         else{
  156.             $t = taxonomy_get_term_by_name($session_country, $vocabulary = "country_action");
  157.             $tid = array(1510,2160);
  158.             foreach($t as $key=>$value){
  159.             $tid[] = $key;
  160.             $child = taxonomy_get_children($key);
  161.                 foreach($child as $key_tid =>$child_value){
  162.                     $tax_node = taxonomy_select_nodes($key_tid,$pager = FALSE);
  163.                       if(isset($tax_node[0])){
  164.                         $tid[] = $key_tid;
  165.                     }
  166.                 }
  167.             }
  168.             $tid_for_js = json_encode($tid);
  169.             drupal_add_js('jQuery(document).ready(function () {
  170.                var tid = '.$tid_for_js.';
  171.                if ($("#views-exposed-form-rf-page").length > 0){
  172.                    var filter = $("#views-exposed-form-rf-page select option");
  173.                 }
  174.                else if ($("#views-exposed-form-rf-page-1").length > 0){
  175.                    var filter = $("#views-exposed-form-rf-page-1 select option");
  176.                }
  177.                var count = 0;
  178.                for (var i=0; i < filter.length; i++) {
  179.                      if (filter[i].selected){ count++};
  180.                }
  181.                
  182.                if(filter.length==count || count==0){
  183.                
  184.                var isChromium = window.chrome,
  185.                    vendorName = window.navigator.vendor;
  186.                if(isChromium !== null && vendorName === "Google Inc.") {
  187.                   filter.each(function(){
  188.                        $(this).removeAttr("selected");
  189.                        option_tid = $(this).val();
  190.                        if($.inArray(parseInt(option_tid), tid)> -1){
  191.                            $(this).attr("selected","selected");
  192.                        }
  193.                    });
  194.                } else {
  195.                   for (var i=0; i < filter.length; i++) {
  196.                      filter[i].removeAttribute("selected");
  197.                      option_tid = $(filter[i]).val();
  198.                        if($.inArray(parseInt(option_tid), tid)> -1){
  199.                            filter[i].setAttribute("selected","selected");
  200.                        }
  201.                    }
  202.                }
  203.  
  204.                    $("#edit-submit-rf").click();
  205.                    
  206.                }
  207.            });', 'inline');
  208.         }            
  209.     }
  210.     ?>
  211. <?php foreach ($rows as $id => $row): ?>
  212.   <div <?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"';  } ?>>
  213.     <?php print $row; ?>
  214.   </div>
  215. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement