ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Protection.php
Go to the documentation of this file.
1 <?php
37 {
39  const PROTECTION_INHERIT = 'inherit';
40  const PROTECTION_PROTECTED = 'protected';
41  const PROTECTION_UNPROTECTED = 'unprotected';
42 
48  protected $_locked;
49 
55  protected $_hidden;
56 
67  public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
68  {
69  // Supervisor?
70  parent::__construct($isSupervisor);
71 
72  // Initialise values
73  if (!$isConditional) {
74  $this->_locked = self::PROTECTION_INHERIT;
75  $this->_hidden = self::PROTECTION_INHERIT;
76  }
77  }
78 
85  public function getSharedComponent()
86  {
87  return $this->_parent->getSharedComponent()->getProtection();
88  }
89 
96  public function getStyleArray($array)
97  {
98  return array('protection' => $array);
99  }
100 
117  public function applyFromArray($pStyles = NULL) {
118  if (is_array($pStyles)) {
119  if ($this->_isSupervisor) {
120  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
121  } else {
122  if (isset($pStyles['locked'])) {
123  $this->setLocked($pStyles['locked']);
124  }
125  if (isset($pStyles['hidden'])) {
126  $this->setHidden($pStyles['hidden']);
127  }
128  }
129  } else {
130  throw new PHPExcel_Exception("Invalid style array passed.");
131  }
132  return $this;
133  }
134 
140  public function getLocked() {
141  if ($this->_isSupervisor) {
142  return $this->getSharedComponent()->getLocked();
143  }
144  return $this->_locked;
145  }
146 
153  public function setLocked($pValue = self::PROTECTION_INHERIT) {
154  if ($this->_isSupervisor) {
155  $styleArray = $this->getStyleArray(array('locked' => $pValue));
156  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
157  } else {
158  $this->_locked = $pValue;
159  }
160  return $this;
161  }
162 
168  public function getHidden() {
169  if ($this->_isSupervisor) {
170  return $this->getSharedComponent()->getHidden();
171  }
172  return $this->_hidden;
173  }
174 
181  public function setHidden($pValue = self::PROTECTION_INHERIT) {
182  if ($this->_isSupervisor) {
183  $styleArray = $this->getStyleArray(array('hidden' => $pValue));
184  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
185  } else {
186  $this->_hidden = $pValue;
187  }
188  return $this;
189  }
190 
196  public function getHashCode() {
197  if ($this->_isSupervisor) {
198  return $this->getSharedComponent()->getHashCode();
199  }
200  return md5(
201  $this->_locked
202  . $this->_hidden
203  . __CLASS__
204  );
205  }
206 
207 }
getStyleArray($array)
Build style array from subcomponents.
Definition: Protection.php:96
setLocked($pValue=self::PROTECTION_INHERIT)
Set locked.
Definition: Protection.php:153
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Protection.php:85
__construct($isSupervisor=FALSE, $isConditional=FALSE)
Create a new PHPExcel_Style_Protection.
Definition: Protection.php:67
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:103
applyFromArray($pStyles=NULL)
Apply styles from array.
Definition: Protection.php:117
const PROTECTION_INHERIT
Protection styles.
Definition: Protection.php:39
Create styles array
The data for the language used.
setHidden($pValue=self::PROTECTION_INHERIT)
Set hidden.
Definition: Protection.php:181
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:92
getHashCode()
Get hash code.
Definition: Protection.php:196