Advertisement
Guest User

Untitled

a guest
May 28th, 2017
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. From 3046296a10ea3116de9fddae12a335d823ffee6b Mon Sep 17 00:00:00 2001
  2. From: Anders Ladegaard Marchsteiner <alm@2ndeffect.dk>
  3. Date: Tue, 1 Jun 2010 10:17:37 +0200
  4. Subject: [PATCH] Enable selecting of frontpage performances. Initial start of manuel ordering of performances.
  5.  
  6. ---
  7. modules/het/shell/config.xml | 21 ++++++++++-
  8. modules/het/shell/forestillinger.inc | 14 +++++++-
  9. modules/het/shell/frontpage.inc | 64 ++++++++++++++++++++++++++++++---
  10. 3 files changed, 90 insertions(+), 9 deletions(-)
  11.  
  12. diff --git a/modules/het/shell/config.xml b/modules/het/shell/config.xml
  13. index bbf7977..23d13ad 100755
  14. --- a/modules/het/shell/config.xml
  15. +++ b/modules/het/shell/config.xml
  16. @@ -123,7 +123,18 @@
  17. <notnull>true</notnull>
  18. <default>ffffff</default>
  19. </field>
  20. -
  21. + <field>
  22. + <name>first_performance</name>
  23. + <type>integer</type>
  24. + </field>
  25. + <field>
  26. + <name>secound_performance</name>
  27. + <type>integer</type>
  28. + </field>
  29. + <field>
  30. + <name>third_performance</name>
  31. + <type>integer</type>
  32. + </field>
  33. <index>
  34. <name>primary</name>
  35. <primary>true</primary>
  36. @@ -167,6 +178,12 @@
  37. <type>clob</type>
  38. </field>
  39. <field>
  40. + <name>ordering</name>
  41. + <type>integer</type>
  42. + <default>0</default>
  43. + <notnull>false</notnull>
  44. + </field>
  45. + <field>
  46. <name>small_image</name>
  47. <type>blob</type>
  48. <length>1000000</length>
  49. @@ -497,4 +514,4 @@
  50. </table>
  51. </database>
  52. </databases>
  53. -</module>
  54. \ No newline at end of file
  55. +</module>
  56. diff --git a/modules/het/shell/forestillinger.inc b/modules/het/shell/forestillinger.inc
  57. index 0845200..e1bbe2e 100755
  58. --- a/modules/het/shell/forestillinger.inc
  59. +++ b/modules/het/shell/forestillinger.inc
  60. @@ -10,7 +10,7 @@ class forestillinger_controller extends controller
  61.  
  62. public function _default()
  63. {
  64. - $this->performances = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY title");
  65. + $this->performances = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY ordering");
  66.  
  67. $this->_render("forestillinger");
  68. }
  69. @@ -24,4 +24,16 @@ class forestillinger_controller extends controller
  70.  
  71. header("Location: ".DIRECTORY."Forestillinger");
  72. }
  73. +
  74. + public function MoveUp()
  75. + {
  76. + $ID = $this->params["GET"]["ID"];
  77. + echo $ID;exit;
  78. + }
  79. +
  80. + public function MoveDown()
  81. + {
  82. + $ID = $this->params["GET"]["ID"];
  83. + echo $ID;exit;
  84. + }
  85. }
  86. \ No newline at end of file
  87. diff --git a/modules/het/shell/frontpage.inc b/modules/het/shell/frontpage.inc
  88. index c21c548..a166331 100755
  89. --- a/modules/het/shell/frontpage.inc
  90. +++ b/modules/het/shell/frontpage.inc
  91. @@ -1,6 +1,7 @@
  92. <?php
  93. class frontpage_controller extends controller
  94. {
  95. + protected $performances;
  96. protected $top_performance;
  97. protected $next_two_performances = array();
  98. protected $frontpage;
  99. @@ -12,15 +13,40 @@ class frontpage_controller extends controller
  100.  
  101. public function _default()
  102. {
  103. - $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY ".$this->_get_instance()."_performance_id DESC");
  104. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_frontpage WHERE ".$this->_get_instance()."_frontpage_id = 1");
  105. + $this->frontpage = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  106. +
  107. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY title");
  108. + $this->performances = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
  109. +
  110. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["first_performance"]);
  111. $this->top_performance = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  112. -
  113. +
  114. + if($this->top_performance == null)
  115. + {
  116. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
  117. + $this->top_performance = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  118. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET first_performance = ".$this->top_performance[$this->_get_instance()."_performance_id"]);
  119. + }
  120. +
  121. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["secound_performance"]);
  122. $this->next_two_performances[] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  123. + if(end($this->next_two_performances) == null)
  124. + {
  125. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
  126. + $this->next_two_performances[count($this->next_two_performances)-1] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  127. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET secound_performance = ".$this->next_two_performances[count($this->next_two_performances)-1][$this->_get_instance()."_performance_id"]);
  128. + }
  129. +
  130. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["third_performance"]);
  131. $this->next_two_performances[] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  132. -
  133. - $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_frontpage WHERE ".$this->_get_instance()."_frontpage_id = 1");
  134. - $this->frontpage = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  135. -
  136. + if(end($this->next_two_performances) == null)
  137. + {
  138. + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
  139. + $this->next_two_performances[count($this->next_two_performances)-1] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  140. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET third_performance = ".$this->next_two_performances[count($this->next_two_performances)-1][$this->_get_instance()."_performance_id"]);
  141. + }
  142. +
  143. $this->_render("frontpage");
  144. }
  145.  
  146. @@ -90,4 +116,30 @@ class frontpage_controller extends controller
  147.  
  148. header("Location: ".DIRECTORY."Forside");
  149. }
  150. +
  151. + public function ChangeFirstPerformance()
  152. + {
  153. + $ID = addslashes($this->params["POST"]["performance"]);
  154. +
  155. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET first_performance = ".$ID);
  156. +
  157. + header("Location: ".DIRECTORY."Forside");
  158. + }
  159. +
  160. + public function ChangePerformance()
  161. + {
  162. + $number = $this->params["GET"]["Number"];
  163. + $ID = addslashes($this->params["POST"]["performance"]);
  164. +
  165. + if($number == 2)
  166. + {
  167. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET secound_performance = ".$ID);
  168. + }
  169. + elseif($number == 3)
  170. + {
  171. + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET third_performance = ".$ID);
  172. + }
  173. +
  174. + header("Location: ".DIRECTORY."Forside");
  175. + }
  176. }
  177. --
  178. 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement