This repository was archived by the owner on Dec 6, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathPseudoArray.php
More file actions
99 lines (83 loc) · 2.21 KB
/
Copy pathPseudoArray.php
File metadata and controls
99 lines (83 loc) · 2.21 KB
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
<?php
class EtuDev_Data_PseudoArray extends EtuDev_PseudoArray_Object implements EtuDev_Data_HighlightDataObject
{
public function __construct($originalData = null)
{
if (is_array($originalData) && count(
$originalData
) == 4 && isset($originalData['table']) && isset($originalData['data']) && isset($originalData['stored'])
) {
// treated like a Zend Db Row
$originalData = $originalData['data'];
}
parent::__construct($originalData);
}
/**
*
* @uses setValuesFromOriginalData()
* @uses _getDefaultData()
* @return EtuDev_Data_PseudoArray
*/
public function _setDefaultData()
{
$this->setValuesFromOriginalData($this->_getDefaultData());
return $this;
}
/**
* to be extended, returns an array with the default data for a new entity
*
* @return array
*/
public function _getDefaultData()
{
return array();
}
/**
* @return EtuDev_Data_PseudoArray
*/
public function _setDefaultDataWhenNull()
{
$this->setValuesOnlyIfNull($this->_getDefaultData());
return $this;
}
/**
* @var array con el highlight data
*/
protected $_highlightData = array();
/**
* @param array|SolrObject|Traversable $data
*
* @return EtuDev_Data_PseudoArray
*/
public function setHighlightData($data)
{
$a = array();
foreach ($data as $field => $value) {
$a[$field] = $value[0];
}
$this->_highlightData = $a;
return $this;
}
public function isHighlighted($origkey)
{
$key = $this->getDefinedAlias($origkey);
return $this->_isHighlighted($key);
}
protected function _isHighlighted($key)
{
return @isset($this->_highlightData[$key]);
}
public function getDirectHighlighted($origkey)
{
$key = $this->getDefinedAlias($origkey);
return $this->_getDirectFromHighlightedData($key);
}
protected function _getDirectFromHighlightedData($key)
{
return @$this->_highlightData[$key];
}
static public function getIdField()
{
return 'id';
}
}