Advertisement
Danack

ConvertedScript

Oct 7th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1.  
  2.  
  3. /*namespace BaseReality\Model*/
  4.  
  5. /*use Intahwebz\Utils as Utils*/
  6.  
  7.  
  8. function ContentFilterData() {
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. this.clearAllTags = function (){
  20. this.tags = {};
  21. this.withoutTags = {};
  22. };
  23.  
  24.  
  25.  
  26. this.getPath = function (){
  27.  
  28. var result = "" + "" + this.page;
  29.  
  30. var separator = "?";
  31.  
  32. for (var tagKey in this.tags) {
  33. var tag = this.tags[tagKey];
  34. if(tag == null){
  35. tag = '';
  36. }
  37. result += separator + "" + "tags[]=" + "" + tag;
  38. separator = "&";
  39. }
  40.  
  41. debugger;
  42. for (var withoutTagKey in this.withoutTags) {
  43. var withoutTag = this.withoutTags[withoutTagKey];
  44. if(withoutTag == null){
  45. withoutTag = '';
  46. }
  47. result += separator + "" + "withoutTags[]=" + "" + withoutTag;
  48. separator = "&";
  49. }
  50.  
  51. return result;
  52. };
  53.  
  54.  
  55.  
  56. this.addFilterTag = function (newTag){
  57. for (var tagKey in this.tags) {
  58. var tag = this.tags[tagKey];
  59. if(tag == newTag){
  60. return;
  61. }
  62. }
  63.  
  64. array_push(this.tags, newTag);
  65. this.page = 1;
  66. };
  67.  
  68.  
  69.  
  70. this.removeFilterTag = function (tagText){
  71. var newArray = {};
  72. for (var tagKey in this.tags) {
  73. var tag = this.tags[tagKey];
  74. if(tag != tagText){
  75. array_push(newArray, tag);
  76. }
  77. }
  78.  
  79. this.tags = newArray;
  80. this.page = 1;
  81. };
  82.  
  83.  
  84.  
  85. this.addWithoutTag = function (newTag){
  86. for (var withoutTagKey in this.withoutTags) {
  87. var withoutTag = this.withoutTags[withoutTagKey];
  88. if(withoutTag == newTag){
  89. return;
  90. }
  91. }
  92.  
  93. array_push(this.withoutTags, newTag);
  94. this.page = 1;
  95. };
  96.  
  97.  
  98.  
  99. this.removeWithoutTag = function (tagText){
  100. var newArray = {};
  101. for (var tagKey in this.withoutTags) {
  102. var tag = this.withoutTags[tagKey];
  103. if(tag != tagText){
  104. array_push(newArray, tag);
  105. }
  106. }
  107.  
  108. this.tags = newArray;
  109. this.page = 1;
  110. };
  111.  
  112.  
  113.  
  114. // function setMode($mode){
  115. // switch($mode){
  116. // case('withoutTag'):{
  117. // $withoutTags = array();
  118. // break;
  119. // }
  120. //
  121. // default:{
  122. // throw new \Exception("Unknown mode in ContentFilterData [". $mode."]");
  123. // }
  124. // }
  125. // }
  126.  
  127. this.nextPage = function (){
  128. if(this.page < this.maxPages){
  129. this.page += 1;
  130. }
  131. };
  132.  
  133.  
  134.  
  135. this.previousPage = function (){
  136. if(this.page > 1){
  137. this.page -= 1;
  138. }
  139. };
  140.  
  141.  
  142.  
  143. this.firstPage = function (){
  144. this.page = 1;
  145. };
  146.  
  147.  
  148.  
  149. this.lastPage = function (){
  150. this.page = this.maxPages;
  151. };
  152.  
  153.  
  154.  
  155. this.goToPage = function (newPage){
  156.  
  157. /** @noinspection PhpSillyAssignmentInspection */
  158. newPage = +newPage;
  159.  
  160. if(newPage < 1){
  161. newPage = 1;
  162. }
  163. if(newPage > this.maxPages){
  164. newPage = this.maxPages;
  165. }
  166.  
  167. this.page = newPage;
  168. };
  169.  
  170.  
  171. this.page = null;
  172. this.maxPages = null;
  173. this.itemsPerPage = null;
  174. this.tags = null;
  175. this.withoutTags = null;
  176.  
  177. this.page = 1;
  178. this.maxPages = 1;
  179. this.tags = {};
  180. this.withoutTags = {};
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement