partia duużych zmian
[watermeloncms.git] / wtrmln / modules / models / model_pages.php
blob24027b2363bfe332ccd2b0bedda20f54ae7165b1
1 <?php
2 /********************************************************************
4 Watermelon CMS
6 Copyright 2008-2009 Radosław Pietruszewski
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ********************************************************************/
23 class Model_Pages extends Model
26 * public DBresult GetPages()
28 * pobiera strony
31 public function GetPages()
33 return $this->db->query("SELECT * FROM `__pages` ORDER BY `id` DESC");
37 * public DBresult GetData(string $pagename)
39 * zwraca dane page'a o nazwie $pagename
42 public function GetData($pagename)
44 $pagename = mysql_real_escape_string($pagename);
46 return $this->db->query("SELECT `content`, `title` FROM `__pages` WHERE `name` = '%1'", $pagename);
50 * public DBresult GetData(int $pageID)
52 * zwraca dane page'a o ID $pageID
55 public function GetDataByID($pageID)
57 $pageID = intval($pageID);
59 return $this->db->query("SELECT * FROM `__pages` WHERE `id` = '%1'", $pageID);
63 * public void Post(string $title, string $name, string $text)
65 * tworzy stronę o tytule $title, z treścią $text i nazwą $name
68 public function Post($title, $name, $text)
70 $title = mysql_real_escape_string($title);
71 $name = mysql_real_escape_string($name);
72 $text = mysql_real_escape_string($text);
74 $this->db->query("INSERT INTO `__pages` (`name`, `content`, `title`) VALUES ('%1', '%2', '%3')", $name, $text, $title);
78 * public void Edit(uint $id, string $title, string $name, string $text)
80 * ustala stronie o ID = $id tytuł $title, nazwę $name oraz treść $text
83 public function Edit($id, $title, $name, $text)
85 $title = mysql_real_escape_string($title);
86 $text = mysql_real_escape_string($text);
87 $name = mysql_real_escape_string($name);
88 $id = intval($id);
90 $this->db->query("UPDATE `__pages` SET `title` = '%1', `content` = '%2', `name` = '%3' WHERE `id` = '%4'", $title, $text, $name, $id);
94 * public void Delete(uint $id)
96 * Usuwa stronę o ID = $id
99 public function Delete($id)
101 $id = intval($id);
102 $this->db->query("DELETE FROM `__pages` WHERE `id` = '%1'", $id);