Advertisement
ChibiTaisen

Health/Mood Problem for Myadoptsview.php

Jul 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.12 KB | None | 0 0
  1. <?php
  2.  
  3. use Resource\Native\String;
  4. use Resource\Collection\LinkedList;
  5. use Resource\Collection\LinkedHashMap;
  6.  
  7. class MyadoptsView extends View{
  8.  
  9. public function index(){
  10. $mysidia = Registry::get("mysidia");
  11. $document = $this->document;
  12. $document->setTitle($this->lang->title);
  13.  
  14. $pagination = $this->getField("pagination");
  15. $stmt = $this->getField("stmt")->get();
  16. if($stmt->rowCount() == 0){
  17. $document->addLangvar($this->lang->empty);
  18. return;
  19. }
  20.  
  21. $adoptTable = new TableBuilder("adopttable", 650);
  22. $adoptTable->setAlign(new Align("center", "middle"));
  23. $adoptTable->buildHeaders("Name/Type", "Element", "Gender", "Image", "Clicks", "Level");
  24.  
  25. while($aid = $stmt->fetchColumn()){
  26. $adopt = new OwnedAdoptable($aid);
  27. $cells = new LinkedList;
  28. $cells->add(new TCell("<em>{$adopt->getName()}</em> the {$adopt->getType()}"));
  29. $cells->add(new TCell($adopt->getElement("gui")));
  30. $cells->add(new TCell($adopt->getGender("gui")));
  31. $cells->add(new TCell(new Link("myadopts/manage/{$aid}", $adopt->getImage("gui"))));
  32. $cells->add(new TCell($adopt->getTotalClicks()));
  33. $cells->add(new TCell($adopt->getCurrentLevel()));
  34. $adoptTable->buildRow($cells);
  35. }
  36. $document->add($adoptTable);
  37. $document->addLangvar($pagination->showPage());
  38. }
  39.  
  40. public function manage(){
  41. $mysidia = Registry::get("mysidia");
  42. $adopt = $this->getField("adopt");
  43. $aid = $this->getField("aid")->getValue();
  44. $name = $this->getField("name")->getValue();
  45. $image = $this->getField("image");
  46. $health = $adopt->getHealth();
  47. $mood = $adopt->getMood();
  48. $addHealth = $adopt->getHealth() + 10;
  49. $addMood = $adopt->getMood() + 10;
  50. $subtractHealth = $adopt->getHealth() - 10;
  51. $subtractMood = $adopt->getMood() - 10;
  52.  
  53. $document = $this->document;
  54. $document->setTitle("Managing {$name}");
  55. $document->add($image);
  56. $document->add(new Comment ("Health: <progress max='100' value='{$health}'></progress> <br></br>Mood: <progress max='100' value='{$mood}'></progress>"));
  57. $document->add(new Comment("<br><br>Here is this page where you can manage {$name}. Click on an option below to change settings.<br>"));
  58.  
  59. $document->add(new Image("templates/icons/add.gif"));
  60. $document->add(new Link("levelup/click/{$aid}", " Level Up {$name}", TRUE));
  61. $document->add(new Link("levelup/publicprofile/{$aid}", " View {$name}'s Profile", TRUE));
  62. $document->add(new Image("templates/icons/stats.gif"));
  63. $document->add(new Link("myadopts/stats/{$aid}", " Get Stats for {$name}", TRUE));
  64. $document->add(new Image("templates/icons/bbcodes.gif"));
  65. $document->add(new Link("myadopts/bbcode/{$aid}", " Get BBCodes / HTML Codes for {$name}", TRUE));
  66. $document->add(new Image("templates/icons/title.gif"));
  67. $document->add(new Link("myadopts/rename/{$aid}", " Rename {$name}", TRUE));
  68. $document->add(new Image("templates/icons/trade.gif"));
  69. $document->add(new Link("myadopts/trade/{$aid}", " Change Trade status for {$name}", TRUE));
  70. $document->add(new Image("templates/icons/freeze.gif"));
  71. $document->add(new Link("myadopts/freeze/{$aid}", " Freeze or Unfreeze {$name}", TRUE));
  72. $document->add(new Image("templates/icons/delete.gif"));
  73. $document->add(new Link("pound/pound/{$aid}", " Pound {$name}", TRUE));
  74. }
  75.  
  76. public function stats(){
  77. $mysidia = Registry::get("mysidia");
  78. $adopt = $this->getField("adopt");
  79. $image = $this->getField("image");
  80. $stmt = $this->getField("stmt")->get();
  81.  
  82. $document = $this->document;
  83. $document->setTitle($adopt->getName().$this->lang->stats);
  84. $document->add($image);
  85. $document->add($adopt->getStats());
  86. $document->addLangvar("<h2>{$adopt->getName()}'s Voters:</h2><br>{$this->lang->voters}<br><br>");
  87.  
  88. $fields = new LinkedHashMap;
  89. $fields->put(new String("username"), new String("getUsername"));
  90. $fields->put(new String("date"), NULL);
  91. $fields->put(new String("username::profile"), new String("getProfileImage"));
  92. $fields->put(new String("username::message"), new String("getPMImage"));
  93.  
  94. $voterTable = new TableBuilder("voters", 500);
  95. $voterTable->setAlign(new Align("center"));
  96. $voterTable->buildHeaders("User", "Date Voted", "Profile", "PM");
  97. $voterTable->setHelper(new UserTableHelper);
  98. $voterTable->buildTable($stmt, $fields);
  99. $document->add($voterTable);
  100. }
  101.  
  102. public function bbcode(){
  103. $mysidia = Registry::get("mysidia");
  104. $adopt = $this->getField("adopt");
  105. $document = $this->document;
  106. $document->setTitle($this->lang->bbcode.$adopt->getName());
  107. $document->addLangvar($this->lang->bbcode_info);
  108. $document->add(new Comment("<br>"));
  109.  
  110. $forumComment = new Comment("Forum BBCode: ");
  111. $forumComment->setUnderlined();
  112. $forumcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}[/img][/url]";
  113. $forumArea = new TextArea("forumcode", $forumcode, 4, 50);
  114. $forumArea->setReadOnly(TRUE);
  115.  
  116. $altComment = new Comment("Alternative BBCode: ");
  117. $altComment->setUnderlined();
  118. $altcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif\"[/img][/url]";
  119. $altArea = new TextArea("altcode", $altcode, 4, 50);
  120. $altArea->setReadOnly(TRUE);
  121.  
  122. $htmlComment = new Comment("HTML BBCode: ");
  123. $htmlComment->setUnderlined();
  124. $htmlcode = "<a href='{$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}' target='_blank'>
  125. <img src='{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}' border=0></a>";
  126. $htmlArea = new TextArea("htmlcode", $htmlcode, 4, 50);
  127. $htmlArea->setReadOnly(TRUE);
  128.  
  129. $document->add($forumComment);
  130. $document->add($forumArea);
  131. $document->add($altComment);
  132. $document->add(($mysidia->settings->usealtbbcode == "yes")?$altArea:new Comment("The Admin has disabled Alt BBCode for this site."));
  133. $document->add($htmlComment);
  134. $document->add($htmlArea);
  135. }
  136.  
  137. public function rename(){
  138. $mysidia = Registry::get("mysidia");
  139. $adopt = $this->getField("adopt");
  140. $image = $this->getField("image");
  141. $document = $this->document;
  142.  
  143. if($mysidia->input->post("submit")){
  144. $document->setTitle($this->lang->rename_success_title);
  145. $document->add($image);
  146. $message = "<br>{$this->lang->rename_success}{$mysidia->input->post("adoptname")}.
  147. You can now manage {$mysidia->input->post("adoptname")} on the";
  148. $document->addLangvar($message);
  149. $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));
  150. return;
  151. }
  152.  
  153. $document->setTitle($this->lang->rename.$adopt->getName());
  154. $document->add($image);
  155. $document->addLangvar("<br />{$this->lang->rename_default}{$adopt->getName()}{$this->lang->rename_details}<br />");
  156.  
  157. $renameForm = new FormBuilder("renameform", "", "post");
  158. $renameForm->buildTextField("adoptname")->buildButton("Rename Adopt", "submit", "submit");
  159. $document->add($renameForm);
  160. }
  161.  
  162. public function trade(){
  163. $mysidia = Registry::get("mysidia");
  164. $aid = $this->getField("aid")->getValue();
  165. $image = $this->getField("image");
  166. $message = $this->getField("message")->getValue();
  167. $document = $this->document;
  168. $document->setTitle($this->lang->trade);
  169. $document->add($image);
  170. $document->addLangvar($message);
  171. }
  172.  
  173. public function freeze(){
  174. $mysidia = Registry::get("mysidia");
  175. $adopt = $this->getField("adopt");
  176. $image = $this->getField("image");
  177. $message = $this->getField("message")->getValue();
  178. $document = $this->document;
  179. $document->setTitle($this->lang->freeze);
  180.  
  181. if($mysidia->input->get("confirm") == "confirm"){
  182. $document->addLangvar($message);
  183. $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));
  184. }
  185. else{
  186. $document->add($image);
  187. $document->add(new Comment("<br /><b>{$adopt->getName()}'s Current Status: "));
  188.  
  189. if($adopt->isfrozen() == "yes"){
  190. $document->add(new Image("templates/icons/freeze.gif", "Frozen"));
  191. $document->add(new Comment("Frozen<br<br>"));
  192. $document->add(new Comment($this->lang->freeze));
  193. $document->add(new Image("templates/icons/unfreeze.gif", "Unfreeze"));
  194. $document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Unfreeze this Adoptable", TRUE));
  195. }
  196. else{
  197. $document->add(new Image("templates/icons/unfreeze.gif", "Not Frozen"));
  198. $document->add(new Comment("Not Frozen<br><br>"));
  199. $document->add(new Comment($this->lang->freeze));
  200. $document->add(new Image("templates/icons/freeze.gif", "Greeze"));
  201. $document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Freeze this Adoptable", TRUE));
  202. }
  203. $document->add(new Comment("<br><br>"));
  204. $document->add(new Image("templates/icons/warning.gif"));
  205. $document->addLangvar($this->lang->freeze_warning);
  206. }
  207. }
  208. }
  209. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement