XOOPS  2.6.0
menu.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
14 
24 class MenusMenu extends XoopsObject
25 {
29  public function __construct()
30  {
31  $this->initVar('id', XOBJ_DTYPE_INT);
32  $this->initVar('pid', XOBJ_DTYPE_INT);
33  $this->initVar('mid', XOBJ_DTYPE_INT);
34  $this->initVar('title', XOBJ_DTYPE_TXTBOX, '');
35  $this->initVar('alt_title', XOBJ_DTYPE_TXTBOX, '');
36  $this->initVar('visible', XOBJ_DTYPE_INT, 1);
37  $this->initVar('link', XOBJ_DTYPE_TXTBOX);
38  $this->initVar('weight', XOBJ_DTYPE_INT, 255);
39  $this->initVar('target', XOBJ_DTYPE_TXTBOX, '_self');
40  $this->initVar('groups', XOBJ_DTYPE_ARRAY, serialize(array(FixedGroups::ANONYMOUS, FixedGroups::USERS)));
41  $this->initVar('hooks', XOBJ_DTYPE_ARRAY, serialize(array()));
42  $this->initVar('image', XOBJ_DTYPE_TXTBOX);
43  $this->initVar('css', XOBJ_DTYPE_TXTBOX);
44  }
45 }
46 
48 {
52  public function __construct(Connection $db = null)
53  {
54  parent::__construct($db, 'menus_menu', 'MenusMenu', 'id', 'title');
55  }
56 
60  public function update_weights(MenusMenu $obj)
61  {
62  $sql = "UPDATE " . $this->table
63  . " SET weight = weight+1"
64  . " WHERE weight >= " . $obj->getVar('weight')
65  . " AND id <> " . $obj->getVar('id')
66  /*. " AND pid = " . $obj->getVar('pid')*/
67  . " AND mid = " . $obj->getVar('mid')
68  ;
69  $this->db->queryF($sql);
70 
71  $sql = "SELECT id FROM " . $this->table
72  . " WHERE mid = " . $obj->getVar('mid')
73  /*. " AND pid = " . $obj->getVar('pid')*/
74  . " ORDER BY weight ASC"
75  ;
76  $result = $this->db->query($sql);
77  $i = 1; //lets start at 1 please!
78  while (list($id) = $this->db->fetchrow($result)) {
79  $sql = "UPDATE " . $this->table
80  . " SET weight = {$i}"
81  . " WHERE id = {$id}"
82  ;
83  $this->db->queryF($sql);
84  ++$i;
85  }
86  }
87 }
__construct(Connection $db=null)
Definition: menu.php:52
update_weights(MenusMenu $obj)
Definition: menu.php:60
$result
Definition: pda.php:33
getVar($key, $format= 's')
__construct()
Definition: menu.php:29
$id
Definition: admin_menu.php:36
$i
Definition: menu.php:24
$sql
Definition: pda.php:32
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')