1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Mastopgo2; |
4
|
|
|
|
5
|
|
|
### ============================================================= |
6
|
|
|
### Mastop InfoDigital - Paixão por Internet |
7
|
|
|
### ============================================================= |
8
|
|
|
### Classe para Manipulação de Destaques |
9
|
|
|
### ============================================================= |
10
|
|
|
### Developer: Fernando Santos (topet05), [email protected] |
11
|
|
|
### Copyright: Mastop InfoDigital © 2003-2007 |
12
|
|
|
### ------------------------------------------------------------- |
13
|
|
|
### www.mastop.com.br |
14
|
|
|
### ============================================================= |
15
|
|
|
### |
16
|
|
|
### ============================================================= |
17
|
|
|
|
18
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/' . MGO_MOD_DIR . '/class/mastopgeral.class.php'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class Go2 |
22
|
|
|
*/ |
23
|
|
|
class Go2 extends Mastop |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* mgo_go2_go2 constructor. |
27
|
|
|
* @param null $id |
|
|
|
|
28
|
|
|
*/ |
29
|
|
|
public function __construct($id = null) |
30
|
|
|
{ |
31
|
|
|
$this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
32
|
|
|
$this->tabela = $this->db->prefix(MGO_MOD_TABELA1); |
33
|
|
|
$this->id = 'go2_10_id'; |
34
|
|
|
$this->initVar('go2_10_id', XOBJ_DTYPE_INT, 0); |
35
|
|
|
$this->initVar('sec_10_id', XOBJ_DTYPE_INT, 0); |
36
|
|
|
$this->initVar('go2_30_nome', XOBJ_DTYPE_TXTBOX); |
37
|
|
|
$this->initVar('go2_30_link', XOBJ_DTYPE_URL); |
38
|
|
|
$this->initVar('go2_11_target', XOBJ_DTYPE_INT, 0); |
39
|
|
|
$this->initVar('go2_30_imagem', XOBJ_DTYPE_TXTBOX); |
40
|
|
|
$this->initVar('go2_10_acessos', XOBJ_DTYPE_INT, 0); |
41
|
|
|
$this->initVar('go2_12_ativo', XOBJ_DTYPE_INT, 1); |
42
|
|
|
|
43
|
|
|
if (!empty($id)) { |
44
|
|
|
if (is_array($id)) { |
45
|
|
|
$this->assignVars($id); |
46
|
|
|
} else { |
47
|
|
|
$this->load((int)$id); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return bool |
54
|
|
|
*/ |
55
|
|
|
public function ativar() |
56
|
|
|
{ |
57
|
|
|
$sql = 'UPDATE ' . $this->tabela . ' SET go2_12_ativo=1 WHERE ' . $this->id . '=' . $this->getVar($this->id); |
58
|
|
|
if (!$result = $this->db->queryF($sql)) { |
|
|
|
|
59
|
|
|
return false; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return true; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function desativar() |
69
|
|
|
{ |
70
|
|
|
$sql = 'UPDATE ' . $this->tabela . ' SET go2_12_ativo=0 WHERE ' . $this->id . '=' . $this->getVar($this->id); |
71
|
|
|
if (!$result = $this->db->queryF($sql)) { |
|
|
|
|
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return true; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param bool $html |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function pegaImagem($html = false) |
84
|
|
|
{ |
85
|
|
|
return (!$html) ? XOOPS_URL . $this->getVar('go2_30_imagem') : "<img src='" . XOOPS_URL . $this->getVar('go2_30_imagem') . "' alt='" . $this->getVar('go2_30_nome') . "' class='full'>"; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param bool $imagem |
90
|
|
|
* @param bool $html |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function pegaLink($imagem = false, $html = true) |
95
|
|
|
{ |
96
|
|
|
if (!$html) { |
97
|
|
|
if ('' === $this->getVar('go2_30_link')) { |
98
|
|
|
} else { |
99
|
|
|
return XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/go2.php?tac=' . $this->getVar($this->id); |
100
|
|
|
} |
101
|
|
|
} else { |
102
|
|
|
if (!$imagem) { |
103
|
|
|
if (0 == $this->getVar('go2_11_target')) { |
104
|
|
|
return "<a href='" . XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/go2.php?tac=' . $this->getVar($this->id) . "' title='" . $this->getVar('go2_30_nome') . "'>" . $this->getVar('go2_30_link') . '</a>'; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return "<a href='" . XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/go2.php?tac=' . $this->getVar($this->id) . "' title='" . $this->getVar('go2_30_nome') . "' target='_blank'>" . $this->getVar('go2_30_link') . '</a>'; |
108
|
|
|
} |
109
|
|
|
if (0 == $this->getVar('go2_11_target')) { |
110
|
|
|
return "<a href='" . XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/go2.php?tac=' . $this->getVar($this->id) . "' title='" . $this->getVar('go2_30_nome') . "'>" . $this->pegaImagem(true) . '</a>'; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return "<a href='" . XOOPS_URL . '/modules/' . MGO_MOD_DIR . '/go2.php?tac=' . $this->getVar($this->id) . "' title='" . $this->getVar('go2_30_nome') . "' target='_blank'>" . $this->pegaImagem(true) . '</a>'; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return bool |
119
|
|
|
*/ |
120
|
|
|
public function atualizaCount() |
121
|
|
|
{ |
122
|
|
|
$sql = 'UPDATE ' . $this->tabela . ' SET go2_10_acessos=go2_10_acessos+1 WHERE ' . $this->id . '=' . $this->getVar($this->id); |
123
|
|
|
if (!$result = $this->db->queryF($sql)) { |
|
|
|
|
124
|
|
|
return false; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return true; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|