/
helper.php
107 lines (91 loc) · 3.17 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
class comEqZonalesAdminHelper
{
/** @var JCache */
var $_cache = null;
function __construct($default = array())
{
$this->_cache =& JFactory::getCache('com_zonales');
}
/**
* Recupera una lista de los items de menu publicados en Joomla!
*
* @return array Lista de menùes recuperados
*/
function getJoomlaMenuItems()
{
$dbo = & JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('m.id') .', '. $dbo->nameQuote('m.name')
.' FROM ' . $dbo->nameQuote('#__menu') . ' m'
.' WHERE '. $dbo->nameQuote('published') . ' = 1';
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
/**
* Recupera una lista de los fields cargados en CP.
*
* @return array Lista de zonales recuperados
*/
function getCpFields()
{
$dbo = & JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('f.id') .', '. $dbo->nameQuote('f.name') .', '. $dbo->nameQuote('f.label')
.' FROM ' . $dbo->nameQuote('#__custom_properties_fields') . ' f';
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
/**
* Recupera información acerca de un tipo de tag.
* @param string $tipo nombre del tipo a recuperar
* @return object información del tipo recuperado
*/
function getTipo($tipo)
{
if (is_null($tipo)) {
return null;
}
$dbo = & JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('t.id') .', '. $dbo->nameQuote('t.tipo')
.' FROM ' . $dbo->nameQuote('#__zonales_tipotag') . ' t'
.' WHERE '. $dbo->nameQuote('t.tipo') .' = '. $dbo->quote($tipo);
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObject'), array());
}
/**
* Recupera una lista de fields usados en los menues
*
* @return array Lista de fields recuperados
*/
function getCpMenuFields()
{
$tipo = $this->getTipo('menu');
$dbo = & JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('f.id') .', '. $dbo->nameQuote('f.name') .', '. $dbo->nameQuote('f.label')
.' FROM ' . $dbo->nameQuote('#__custom_properties_fields') . ' f'
.' INNER JOIN '. $dbo->nameQuote('#__zonales_cp2tipotag') . ' tt'
.' ON '. $dbo->nameQuote('tt.field_id') .' = '. $dbo->nameQuote('f.id')
.' AND '. $dbo->nameQuote('tt.tipo_id') .' = '. $tipo->id;
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
/**
* Recupera una lista de los values asociados a un tag menu.
*
* @return array Lista de values recuperados
*/
function getCpMenuValues($field_id)
{
$tipo = $this->getTipo('menu');
$dbo = & JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('v.id') .', '. $dbo->nameQuote('v.name') .', '. $dbo->nameQuote('v.label')
.' FROM ' . $dbo->nameQuote('#__custom_properties_values') . ' v'
.' INNER JOIN '. $dbo->nameQuote('#__zonales_cp2tipotag') . ' tt'
.' ON '. $dbo->nameQuote('tt.field_id') .' = '. $dbo->nameQuote('v.field_id')
.' AND '. $dbo->nameQuote('tt.tipo_id') .' = '. $tipo->id
.' AND '. $dbo->nameQuote('tt.field_id') .' = '. $field_id;
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
}