ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAssOrderingElement.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
14 
15  public static $objectInstanceCounter = 0;
17 
27  public $id = -1;
28 
38  protected $randomIdentifier = null;
39 
52  protected $solutionIdentifier = null;
53 
59  protected $indentation = 0;
60 
66  protected $position = null;
67 
71  protected $content = null;
72 
76  protected $uploadImageName = null;
77 
81  protected $uploadImageFile = null;
82 
86  protected $imageRemovalRequest = null;
87 
91  protected $imagePathWeb = null;
92 
96  protected $imagePathFs = null;
97 
101  protected $imageThumbnailPrefix = null;
102 
106  public function __construct()
107  {
108  $this->objectInstanceId = ++self::$objectInstanceCounter;
109  }
110 
114  public function __clone()
115  {
116  $this->objectInstanceId = ++self::$objectInstanceCounter;
117  }
118 
122  public function getClone()
123  {
124  return clone $this;
125  }
126 
130  public function getId()
131  {
132  return $this->id;
133  }
134 
138  public function setId($id)
139  {
140  $this->id = $id;
141  }
142 
146  public function getRandomIdentifier()
147  {
149  }
150 
155  {
156  $this->randomIdentifier = $randomIdentifier;
157  }
158 
162  public function getSolutionIdentifier()
163  {
165  }
166 
171  {
172  $this->solutionIdentifier = $solutionIdentifier;
173  }
174 
178  public function setIndentation($indentation)
179  {
180  $this->indentation = $indentation;
181  }
182 
186  public function getIndentation()
187  {
188  return $this->indentation;
189  }
190 
194  public function getPosition()
195  {
196  return $this->position;
197  }
198 
202  public function setPosition($position)
203  {
204  $this->position = $position;
205  }
206 
210  public function getContent()
211  {
212  return $this->content;
213  }
214 
218  public function setContent($content)
219  {
220  $this->content = $content;
221  }
222 
226  public function getUploadImageFile()
227  {
228  return $this->uploadImageFile;
229  }
230 
235  {
236  $this->uploadImageFile = $uploadImageFile;
237  }
238 
242  public function getUploadImageName()
243  {
244  return $this->uploadImageName;
245  }
246 
251  {
252  $this->uploadImageName = $uploadImageName;
253  }
254 
258  public function isImageUploadAvailable()
259  {
260  return (bool) strlen($this->getUploadImageFile());
261  }
262 
266  public function isImageRemovalRequest()
267  {
269  }
270 
275  {
276  $this->imageRemovalRequest = $imageRemovalRequest;
277  }
278 
282  public function getImagePathWeb()
283  {
284  return $this->imagePathWeb;
285  }
286 
291  {
292  $this->imagePathWeb = $imagePathWeb;
293  }
294 
298  public function getImagePathFs()
299  {
300  return $this->imagePathFs;
301  }
302 
306  public function setImagePathFs($imagePathFs)
307  {
308  $this->imagePathFs = $imagePathFs;
309  }
310 
314  public function getImageThumbnailPrefix()
315  {
317  }
318 
323  {
324  $this->imageThumbnailPrefix = $imageThumbnailPrefix;
325  }
326 
331  public function isSameElement(ilAssOrderingElement $element)
332  {
333  if ($element->getRandomIdentifier() != $this->getRandomIdentifier()) {
334  return false;
335  }
336 
337  if ($element->getSolutionIdentifier() != $this->getSolutionIdentifier()) {
338  return false;
339  }
340 
341  if ($element->getPosition() != $this->getPosition()) {
342  return false;
343  }
344 
345  if ($element->getIndentation() != $this->getIndentation()) {
346  return false;
347  }
348 
349  return true;
350  }
351 
352  public function getStorageValue1($orderingType)
353  {
354  switch ($orderingType) {
355  case OQ_NESTED_TERMS:
356  case OQ_NESTED_PICTURES:
357 
358  return $this->getPosition();
359 
360  case OQ_TERMS:
361  case OQ_PICTURES:
362 
363  return $this->getSolutionIdentifier();
364  }
365  }
366 
367  public function getStorageValue2($orderingType)
368  {
369  switch ($orderingType) {
370  case OQ_NESTED_TERMS:
371  case OQ_NESTED_PICTURES:
372 
373  return $this->getRandomIdentifier() . ':' . $this->getIndentation();
374 
375  case OQ_TERMS:
376  case OQ_PICTURES:
377 
378  return $this->getPosition() + 1;
379  }
380  }
381 
382  public function __toString()
383  {
384  return $this->getContent();
385  }
386 
387  protected function thumbnailFileExists()
388  {
389  if (!strlen($this->getContent())) {
390  return false;
391  }
392 
393  return file_exists($this->getThumbnailFilePath());
394  }
395 
396  protected function getThumbnailFilePath()
397  {
398  return $this->getImagePathFs() . $this->getImageThumbnailPrefix() . $this->getContent();
399  }
400 
401  protected function getThumbnailFileUrl()
402  {
403  return $this->getImagePathWeb() . $this->getImageThumbnailPrefix() . $this->getContent();
404  }
405 
406  protected function imageFileExists()
407  {
408  if (!strlen($this->getContent())) {
409  return false;
410  }
411 
412  return file_exists($this->getImageFilePath());
413  }
414 
415  protected function getImageFilePath()
416  {
417  return $this->getImagePathFs() . $this->getContent();
418  }
419 
420  protected function getImageFileUrl()
421  {
422  return $this->getImagePathWeb() . $this->getContent();
423  }
424 
425  public function getPresentationImageUrl()
426  {
427  if ($this->thumbnailFileExists()) {
428  return $this->getThumbnailFileUrl();
429  }
430 
431  if ($this->imageFileExists()) {
432  return $this->getImageFileUrl();
433  }
434 
435  return '';
436  }
437 
438  public function getExportIdent()
439  {
440  $ident = array(
441  $this->getRandomIdentifier(),
442  $this->getSolutionIdentifier(),
443  $this->getPosition(),
444  $this->getIndentation()
445  );
446 
447  return implode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
448  }
449 
450  public function isExportIdent($ident)
451  {
452  if (!strlen($ident)) {
453  return false;
454  }
455 
456  $parts = explode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
457 
458  if (count($parts) != 4) {
459  return false;
460  }
461 
463  return false;
464  }
465 
467  return false;
468  }
469 
471  return false;
472  }
473 
475  return false;
476  }
477 
478  return true;
479  }
480 
481  public function setExportIdent($ident)
482  {
483  if ($this->isExportIdent($ident)) {
484  list($randomId, $solutionId, $pos, $indent) = explode(
485  self::EXPORT_IDENT_PROPERTY_SEPARATOR,
486  $ident
487  );
488 
489  $this->setRandomIdentifier($randomId);
490  $this->setSolutionIdentifier($solutionId);
491  $this->setPosition($pos);
492  $this->setIndentation($indent);
493  }
494  }
495 }
isSameElement(ilAssOrderingElement $element)
setSolutionIdentifier($solutionIdentifier)
const OQ_NESTED_TERMS
__construct()
ilAssOrderingElement constructor.
const OQ_PICTURES
Ordering question constants.
setRandomIdentifier($randomIdentifier)
setImageRemovalRequest($imageRemovalRequest)
Create styles array
The data for the language used.
setImageThumbnailPrefix($imageThumbnailPrefix)
const OQ_TERMS
const OQ_NESTED_PICTURES