Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 3046296a10ea3116de9fddae12a335d823ffee6b Mon Sep 17 00:00:00 2001
- From: Anders Ladegaard Marchsteiner <alm@2ndeffect.dk>
- Date: Tue, 1 Jun 2010 10:17:37 +0200
- Subject: [PATCH] Enable selecting of frontpage performances. Initial start of manuel ordering of performances.
- ---
- modules/het/shell/config.xml | 21 ++++++++++-
- modules/het/shell/forestillinger.inc | 14 +++++++-
- modules/het/shell/frontpage.inc | 64 ++++++++++++++++++++++++++++++---
- 3 files changed, 90 insertions(+), 9 deletions(-)
- diff --git a/modules/het/shell/config.xml b/modules/het/shell/config.xml
- index bbf7977..23d13ad 100755
- --- a/modules/het/shell/config.xml
- +++ b/modules/het/shell/config.xml
- @@ -123,7 +123,18 @@
- <notnull>true</notnull>
- <default>ffffff</default>
- </field>
- -
- + <field>
- + <name>first_performance</name>
- + <type>integer</type>
- + </field>
- + <field>
- + <name>secound_performance</name>
- + <type>integer</type>
- + </field>
- + <field>
- + <name>third_performance</name>
- + <type>integer</type>
- + </field>
- <index>
- <name>primary</name>
- <primary>true</primary>
- @@ -167,6 +178,12 @@
- <type>clob</type>
- </field>
- <field>
- + <name>ordering</name>
- + <type>integer</type>
- + <default>0</default>
- + <notnull>false</notnull>
- + </field>
- + <field>
- <name>small_image</name>
- <type>blob</type>
- <length>1000000</length>
- @@ -497,4 +514,4 @@
- </table>
- </database>
- </databases>
- -</module>
- \ No newline at end of file
- +</module>
- diff --git a/modules/het/shell/forestillinger.inc b/modules/het/shell/forestillinger.inc
- index 0845200..e1bbe2e 100755
- --- a/modules/het/shell/forestillinger.inc
- +++ b/modules/het/shell/forestillinger.inc
- @@ -10,7 +10,7 @@ class forestillinger_controller extends controller
- public function _default()
- {
- - $this->performances = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY title");
- + $this->performances = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY ordering");
- $this->_render("forestillinger");
- }
- @@ -24,4 +24,16 @@ class forestillinger_controller extends controller
- header("Location: ".DIRECTORY."Forestillinger");
- }
- +
- + public function MoveUp()
- + {
- + $ID = $this->params["GET"]["ID"];
- + echo $ID;exit;
- + }
- +
- + public function MoveDown()
- + {
- + $ID = $this->params["GET"]["ID"];
- + echo $ID;exit;
- + }
- }
- \ No newline at end of file
- diff --git a/modules/het/shell/frontpage.inc b/modules/het/shell/frontpage.inc
- index c21c548..a166331 100755
- --- a/modules/het/shell/frontpage.inc
- +++ b/modules/het/shell/frontpage.inc
- @@ -1,6 +1,7 @@
- <?php
- class frontpage_controller extends controller
- {
- + protected $performances;
- protected $top_performance;
- protected $next_two_performances = array();
- protected $frontpage;
- @@ -12,15 +13,40 @@ class frontpage_controller extends controller
- public function _default()
- {
- - $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY ".$this->_get_instance()."_performance_id DESC");
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_frontpage WHERE ".$this->_get_instance()."_frontpage_id = 1");
- + $this->frontpage = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- +
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY title");
- + $this->performances = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
- +
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["first_performance"]);
- $this->top_performance = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- -
- +
- + if($this->top_performance == null)
- + {
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
- + $this->top_performance = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET first_performance = ".$this->top_performance[$this->_get_instance()."_performance_id"]);
- + }
- +
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["secound_performance"]);
- $this->next_two_performances[] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- + if(end($this->next_two_performances) == null)
- + {
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
- + $this->next_two_performances[count($this->next_two_performances)-1] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- + $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"]);
- + }
- +
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance WHERE ".$this->_get_instance()."_performance_id = ".$this->frontpage["third_performance"]);
- $this->next_two_performances[] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- -
- - $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_frontpage WHERE ".$this->_get_instance()."_frontpage_id = 1");
- - $this->frontpage = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- -
- + if(end($this->next_two_performances) == null)
- + {
- + $res = $this->db->query("SELECT * FROM ".$this->_get_instance()."_performance ORDER BY RAND(".rand().") LIMIT 1");
- + $this->next_two_performances[count($this->next_two_performances)-1] = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
- + $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"]);
- + }
- +
- $this->_render("frontpage");
- }
- @@ -90,4 +116,30 @@ class frontpage_controller extends controller
- header("Location: ".DIRECTORY."Forside");
- }
- +
- + public function ChangeFirstPerformance()
- + {
- + $ID = addslashes($this->params["POST"]["performance"]);
- +
- + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET first_performance = ".$ID);
- +
- + header("Location: ".DIRECTORY."Forside");
- + }
- +
- + public function ChangePerformance()
- + {
- + $number = $this->params["GET"]["Number"];
- + $ID = addslashes($this->params["POST"]["performance"]);
- +
- + if($number == 2)
- + {
- + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET secound_performance = ".$ID);
- + }
- + elseif($number == 3)
- + {
- + $this->db->exec("UPDATE ".$this->_get_instance()."_frontpage SET third_performance = ".$ID);
- + }
- +
- + header("Location: ".DIRECTORY."Forside");
- + }
- }
- --
- 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement