Cheetah
prof.inc.php
Go to the documentation of this file.
1 <?php
2 
8 define('CH_SYS_PRE_VALUES_TABLE', 'sys_pre_values');
9 
10 $oCache = $GLOBALS['MySQL']->getDbCacheObject();
11 $GLOBALS['aPreValues'] = $oCache->getData($GLOBALS['MySQL']->genDbCacheKey('sys_pre_values'));
12 if (null === $GLOBALS['aPreValues'])
14 
15 function getPreKeys ()
16 {
17  return $GLOBALS['MySQL']->fromCache('sys_prevalues_keys', 'getAll', "SELECT DISTINCT `Key` FROM `" . CH_SYS_PRE_VALUES_TABLE . "`");
18 }
19 
20 function getPreValues ($sKey, $aFields = array(), $iTagsFilter = CH_TAGS_NO_ACTION)
21 {
22  $sqlFields = "*";
23  if (is_array($aFields) && !empty($aFields)) {
24  foreach ($aFields as $sValue)
25  $sqlFields .= "`$sValue`, ";
26  $sqlFields = trim($sqlFields, ', ');
27  }
28  $sqlQuery = "SELECT $sqlFields FROM `" . CH_SYS_PRE_VALUES_TABLE ."`
29  WHERE `Key` = ?
30  ORDER BY `Order` ASC";
31  return $GLOBALS['MySQL']->getAllWithKey($sqlQuery, 'Value', [$sKey]);
32 }
33 
34 function getPreValuesCount ($sKey, $aFields = array(), $iTagsFilter = CH_TAGS_NO_ACTION)
35 {
36  $sKeyDb = process_db_input($sKey, $iTagsFilter);
37  return $GLOBALS['MySQL']->getOne("SELECT COUNT(*) FROM `" . CH_SYS_PRE_VALUES_TABLE . "` WHERE `Key` = '$sKeyDb'");
38 }
39 
40 function compilePreValues()
41 {
42  $GLOBALS['MySQL']->cleanCache('sys_prevalues_keys');
43 
44  $aPreValues = array ();
45  $aKeys = getPreKeys();
46 
47  foreach ($aKeys as $aKey) {
48 
49  $sKey = $aKey['Key'];
50  $aPreValues[$sKey] = array ();
51 
52  $aRows = getPreValues($sKey);
53  foreach ($aRows as $aRow) {
54 
55  $aPreValues[$sKey][$aRow['Value']] = array ();
56 
57  foreach ($aRow as $sValKey => $sValue) {
58  if ($sValKey == 'Key' or $sValKey == 'Value' or $sValKey == 'Order')
59  continue; //skip key, value and order. they already used
60 
61  if (!strlen($sValue))
62  continue; //skip empty values
63 
64  $aPreValues[$sKey][$aRow['Value']][$sValKey] = $sValue;
65  }
66 
67  }
68 
69  }
70 
71  $oCache = $GLOBALS['MySQL']->getDbCacheObject();
72  $oCache->setData ($GLOBALS['MySQL']->genDbCacheKey('sys_pre_values'), $aPreValues);
73 
74  $GLOBALS['aPreValues'] = $aPreValues;
75 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
getPreValuesCount
getPreValuesCount($sKey, $aFields=array(), $iTagsFilter=CH_TAGS_NO_ACTION)
Definition: prof.inc.php:34
getPreKeys
getPreKeys()
Definition: prof.inc.php:15
getPreValues
getPreValues($sKey, $aFields=array(), $iTagsFilter=CH_TAGS_NO_ACTION)
Definition: prof.inc.php:20
php
compilePreValues
compilePreValues()
Definition: prof.inc.php:40
$oCache
$oCache
Definition: prof.inc.php:10
$aFields
$aFields
Definition: preValues.php:19
CH_TAGS_NO_ACTION
const CH_TAGS_NO_ACTION
Definition: utils.inc.php:21
$GLOBALS
$GLOBALS['aPreValues']
Definition: prof.inc.php:11
CH_SYS_PRE_VALUES_TABLE
const CH_SYS_PRE_VALUES_TABLE
Definition: prof.inc.php:8
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
or
Voluntary License Schemes The Licensor waives the right to collect whether individually or
Definition: license.txt:37