ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Borders.php
Go to the documentation of this file.
1 <?php
37 {
38  /* Diagonal directions */
39  const DIAGONAL_NONE = 0;
40  const DIAGONAL_UP = 1;
41  const DIAGONAL_DOWN = 2;
42  const DIAGONAL_BOTH = 3;
43 
49  protected $_left;
50 
56  protected $_right;
57 
63  protected $_top;
64 
70  protected $_bottom;
71 
77  protected $_diagonal;
78 
85 
91  protected $_allBorders;
92 
98  protected $_outline;
99 
105  protected $_inside;
106 
112  protected $_vertical;
113 
119  protected $_horizontal;
120 
131  public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
132  {
133  // Supervisor?
134  parent::__construct($isSupervisor);
135 
136  // Initialise values
137  $this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional);
138  $this->_right = new PHPExcel_Style_Border($isSupervisor, $isConditional);
139  $this->_top = new PHPExcel_Style_Border($isSupervisor, $isConditional);
140  $this->_bottom = new PHPExcel_Style_Border($isSupervisor, $isConditional);
141  $this->_diagonal = new PHPExcel_Style_Border($isSupervisor, $isConditional);
142  $this->_diagonalDirection = PHPExcel_Style_Borders::DIAGONAL_NONE;
143 
144  // Specially for supervisor
145  if ($isSupervisor) {
146  // Initialize pseudo-borders
147  $this->_allBorders = new PHPExcel_Style_Border(TRUE);
148  $this->_outline = new PHPExcel_Style_Border(TRUE);
149  $this->_inside = new PHPExcel_Style_Border(TRUE);
150  $this->_vertical = new PHPExcel_Style_Border(TRUE);
151  $this->_horizontal = new PHPExcel_Style_Border(TRUE);
152 
153  // bind parent if we are a supervisor
154  $this->_left->bindParent($this, '_left');
155  $this->_right->bindParent($this, '_right');
156  $this->_top->bindParent($this, '_top');
157  $this->_bottom->bindParent($this, '_bottom');
158  $this->_diagonal->bindParent($this, '_diagonal');
159  $this->_allBorders->bindParent($this, '_allBorders');
160  $this->_outline->bindParent($this, '_outline');
161  $this->_inside->bindParent($this, '_inside');
162  $this->_vertical->bindParent($this, '_vertical');
163  $this->_horizontal->bindParent($this, '_horizontal');
164  }
165  }
166 
173  public function getSharedComponent()
174  {
175  return $this->_parent->getSharedComponent()->getBorders();
176  }
177 
184  public function getStyleArray($array)
185  {
186  return array('borders' => $array);
187  }
188 
227  public function applyFromArray($pStyles = null) {
228  if (is_array($pStyles)) {
229  if ($this->_isSupervisor) {
230  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
231  } else {
232  if (array_key_exists('left', $pStyles)) {
233  $this->getLeft()->applyFromArray($pStyles['left']);
234  }
235  if (array_key_exists('right', $pStyles)) {
236  $this->getRight()->applyFromArray($pStyles['right']);
237  }
238  if (array_key_exists('top', $pStyles)) {
239  $this->getTop()->applyFromArray($pStyles['top']);
240  }
241  if (array_key_exists('bottom', $pStyles)) {
242  $this->getBottom()->applyFromArray($pStyles['bottom']);
243  }
244  if (array_key_exists('diagonal', $pStyles)) {
245  $this->getDiagonal()->applyFromArray($pStyles['diagonal']);
246  }
247  if (array_key_exists('diagonaldirection', $pStyles)) {
248  $this->setDiagonalDirection($pStyles['diagonaldirection']);
249  }
250  if (array_key_exists('allborders', $pStyles)) {
251  $this->getLeft()->applyFromArray($pStyles['allborders']);
252  $this->getRight()->applyFromArray($pStyles['allborders']);
253  $this->getTop()->applyFromArray($pStyles['allborders']);
254  $this->getBottom()->applyFromArray($pStyles['allborders']);
255  }
256  }
257  } else {
258  throw new PHPExcel_Exception("Invalid style array passed.");
259  }
260  return $this;
261  }
262 
268  public function getLeft() {
269  return $this->_left;
270  }
271 
277  public function getRight() {
278  return $this->_right;
279  }
280 
286  public function getTop() {
287  return $this->_top;
288  }
289 
295  public function getBottom() {
296  return $this->_bottom;
297  }
298 
304  public function getDiagonal() {
305  return $this->_diagonal;
306  }
307 
314  public function getAllBorders() {
315  if (!$this->_isSupervisor) {
316  throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.');
317  }
318  return $this->_allBorders;
319  }
320 
327  public function getOutline() {
328  if (!$this->_isSupervisor) {
329  throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.');
330  }
331  return $this->_outline;
332  }
333 
340  public function getInside() {
341  if (!$this->_isSupervisor) {
342  throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.');
343  }
344  return $this->_inside;
345  }
346 
353  public function getVertical() {
354  if (!$this->_isSupervisor) {
355  throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.');
356  }
357  return $this->_vertical;
358  }
359 
366  public function getHorizontal() {
367  if (!$this->_isSupervisor) {
368  throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.');
369  }
370  return $this->_horizontal;
371  }
372 
378  public function getDiagonalDirection() {
379  if ($this->_isSupervisor) {
380  return $this->getSharedComponent()->getDiagonalDirection();
381  }
383  }
384 
392  if ($pValue == '') {
394  }
395  if ($this->_isSupervisor) {
396  $styleArray = $this->getStyleArray(array('diagonaldirection' => $pValue));
397  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
398  } else {
399  $this->_diagonalDirection = $pValue;
400  }
401  return $this;
402  }
403 
409  public function getHashCode() {
410  if ($this->_isSupervisor) {
411  return $this->getSharedComponent()->getHashcode();
412  }
413  return md5(
414  $this->getLeft()->getHashCode()
415  . $this->getRight()->getHashCode()
416  . $this->getTop()->getHashCode()
417  . $this->getBottom()->getHashCode()
418  . $this->getDiagonal()->getHashCode()
419  . $this->getDiagonalDirection()
420  . __CLASS__
421  );
422  }
423 
424 }
getBottom()
Get Bottom.
Definition: Borders.php:295
getOutline()
Get Outline (pseudo-border).
Definition: Borders.php:327
getDiagonal()
Get Diagonal.
Definition: Borders.php:304
getInside()
Get Inside (pseudo-border).
Definition: Borders.php:340
getAllBorders()
Get AllBorders (pseudo-border).
Definition: Borders.php:314
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:103
getHashCode()
Get hash code.
Definition: Borders.php:409
__construct($isSupervisor=FALSE, $isConditional=FALSE)
Create a new PHPExcel_Style_Borders.
Definition: Borders.php:131
getVertical()
Get Vertical (pseudo-border).
Definition: Borders.php:353
getLeft()
Get Left.
Definition: Borders.php:268
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Borders.php:173
getHorizontal()
Get Horizontal (pseudo-border).
Definition: Borders.php:366
getStyleArray($array)
Build style array from subcomponents.
Definition: Borders.php:184
applyFromArray($pStyles=null)
Apply styles from array.
Definition: Borders.php:227
setDiagonalDirection($pValue=PHPExcel_Style_Borders::DIAGONAL_NONE)
Set DiagonalDirection.
Definition: Borders.php:391
Create styles array
The data for the language used.
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:92
getDiagonalDirection()
Get DiagonalDirection.
Definition: Borders.php:378
getRight()
Get Right.
Definition: Borders.php:277