ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
CacheBase.php
Go to the documentation of this file.
1 <?php
37 
43  protected $_parent;
44 
50  protected $_currentObject = null;
51 
57  protected $_currentObjectID = null;
58 
59 
66  protected $_cellCache = array();
67 
68 
69  public function __construct(PHPExcel_Worksheet $parent) {
70  // Set our parent worksheet.
71  // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
72  // they are woken from a serialized state
73  $this->_parent = $parent;
74  } // function __construct()
75 
76 
84  public function isDataSet($pCoord) {
85  if ($pCoord === $this->_currentObjectID) {
86  return true;
87  }
88  // Check if the requested entry exists in the cache
89  return isset($this->_cellCache[$pCoord]);
90  } // function isDataSet()
91 
92 
100  public function updateCacheData(PHPExcel_Cell $cell) {
101  return $this->addCacheData($cell->getCoordinate(),$cell);
102  } // function updateCacheData()
103 
104 
111  public function deleteCacheData($pCoord) {
112  if ($pCoord === $this->_currentObjectID) {
113  $this->_currentObject->detach();
114  $this->_currentObjectID = $this->_currentObject = null;
115  }
116 
117  if (is_object($this->_cellCache[$pCoord])) {
118  $this->_cellCache[$pCoord]->detach();
119  unset($this->_cellCache[$pCoord]);
120  }
121  } // function deleteCacheData()
122 
123 
129  public function getCellList() {
130  return array_keys($this->_cellCache);
131  } // function getCellList()
132 
133 
139  public function getSortedCellList() {
140  $sortKeys = array();
141  foreach (array_keys($this->_cellCache) as $coord) {
142  list($column,$row) = sscanf($coord,'%[A-Z]%d');
143  $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
144  }
145  ksort($sortKeys);
146 
147  return array_values($sortKeys);
148  } // function sortCellList()
149 
150 
151  protected function _getUniqueID() {
152  if (function_exists('posix_getpid')) {
153  $baseUnique = posix_getpid();
154  } else {
155  $baseUnique = mt_rand();
156  }
157  return uniqid($baseUnique,true);
158  }
159 
165  public function copyCellCollection(PHPExcel_Worksheet $parent) {
166  $this->_parent = $parent;
167  if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) {
168  $this->_currentObject->attach($parent);
169  }
170  } // function copyCellCollection()
171 
172 }