1. PHP / Говнокод #4971

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    function _sortSetting( &$smarty, $urlToSort )
    		{
    			// $sort_string = STRING_PRODUCT_SORT;
    			// $sort_string = str_replace( "{ASC_NAME}",   "<a class='sort_orders' href='".$urlToSort."&sort=name&direction=ASC'>".STRING_ASC."</a>",	$sort_string );
    			// $sort_string = str_replace( "{DESC_NAME}",  "<a class='sort_orders' href='".$urlToSort."&sort=name&direction=DESC'>".STRING_DESC."</a>",	$sort_string );
    			// $sort_string = str_replace( "{ASC_PRICE}",   "<a class='sort_orders' href='".$urlToSort."&sort=Price&direction=ASC'>".STRING_ASC."</a>",	$sort_string );
    			// $sort_string = str_replace( "{DESC_PRICE}",  "<a class='sort_orders' href='".$urlToSort."&sort=Price&direction=DESC'>".STRING_DESC."</a>",	$sort_string );
    			// $sort_string = str_replace( "{ASC_RATING}",   "<a class='sort_orders' href='".$urlToSort."&sort=customers_rating&direction=ASC'>".STRING_ASC."</a>",	$sort_string );
    			// $sort_string = str_replace( "{DESC_RATING}",  "<a class='sort_orders' href='".$urlToSort."&sort=customers_rating&direction=DESC'>".STRING_DESC."</a>",	$sort_string );
    			
    			$selected = array();
    			for ($i = 0; $i < 6; ++$i) {
    				$selected[] = "";
    			}	
    			
    			$i = null;
    			if ($_GET["sort"] == "name") {
    				if ($_GET["direction"] == "ASC") {
    					$i = 0;
    				}
    				else {
    					$i = 1;
    				}
    			}
    			else if ($_GET["sort"] == "Price") {
    				if ($_GET["direction"] == "ASC") {
    					$i = 2;
    				}
    				else {
    					$i = 3;
    				}
    			}
    			else if ($_GET["sort"] == "customers_rating") {
    				if ($_GET["direction"] == "ASC") {
    					$i = 4;
    				}
    				else {
    					$i = 5;
    				}
    			}
    			$selected[$i] = " selected=\"selected\"";	
    			$sort_string = <<<HTML
    <script type="text/javascript">
    
    function go(form) {
    	var i = form.sort.selectedIndex;
    	var direction = "DESC";
    	if (i % 2 == 0) {
    		direction = "ASC";
    	}
    	var sort = "customers_rating";
    	if (i < 2) {
    		sort = "name";
    	}
    	else if (i < 4) {
    		sort = "Price";
    	}
    	var url = "{$urlToSort}&sort=" + sort +"&direction=" + direction;
    	// alert(url);
    	window.location = url;
    }
    			
    </script>			
    <form action="#">
    <p>
    	Сортировать по: <select name="sort" onchange="javascript: go(this.form);">
    		<option value="0"{$selected[0]}>имени / возрастанию</option>
    		<option value="1"{$selected[1]}>имени / убыванию</option>
    		<option value="2"{$selected[2]}>цене / возрастанию</option>
    		<option value="3"{$selected[3]}>цене / убыванию</option>
    		<option value="4"{$selected[4]}>оценке / возрастанию</option>
    		<option value="5"{$selected[5]}>оценке / убыванию</option>
    	</select>
    </p>
    </form>							
    HTML;
    			
    			$smarty->assign( "string_product_sort", $sort_string );
    		}

    да мне до пизды

    Запостил: komprenda, 19 Декабря 2010

    Комментарии (16) RSS

    Добавить комментарий