ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
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  {
335  return false;
336  }
337 
338  if( $element->getSolutionIdentifier() != $this->getSolutionIdentifier() )
339  {
340  return false;
341  }
342 
343  if( $element->getPosition() != $this->getPosition() )
344  {
345  return false;
346  }
347 
348  if( $element->getIndentation() != $this->getIndentation() )
349  {
350  return false;
351  }
352 
353  return true;
354  }
355 
356  public function getStorageValue1($orderingType)
357  {
358  switch( $orderingType )
359  {
360  case OQ_NESTED_TERMS:
361  case OQ_NESTED_PICTURES:
362 
363  return $this->getPosition();
364 
365  case OQ_TERMS:
366  case OQ_PICTURES:
367 
368  return $this->getSolutionIdentifier();
369  }
370  }
371 
372  public function getStorageValue2($orderingType)
373  {
374  switch( $orderingType )
375  {
376  case OQ_NESTED_TERMS:
377  case OQ_NESTED_PICTURES:
378 
379  return $this->getRandomIdentifier() . ':' . $this->getIndentation();
380 
381  case OQ_TERMS:
382  case OQ_PICTURES:
383 
384  return $this->getPosition() + 1;
385  }
386  }
387 
388  public function __toString()
389  {
390  return $this->getContent();
391  }
392 
393  protected function thumbnailFileExists()
394  {
395  if( !strlen($this->getContent()) )
396  {
397  return false;
398  }
399 
400  return file_exists($this->getThumbnailFilePath());
401  }
402 
403  protected function getThumbnailFilePath()
404  {
405  return $this->getImagePathFs() . $this->getImageThumbnailPrefix() . $this->getContent();
406  }
407 
408  protected function getThumbnailFileUrl()
409  {
410  return $this->getImagePathWeb() . $this->getImageThumbnailPrefix() . $this->getContent();
411  }
412 
413  protected function imageFileExists()
414  {
415  if( !strlen($this->getContent()) )
416  {
417  return false;
418  }
419 
420  return file_exists($this->getImageFilePath());
421  }
422 
423  protected function getImageFilePath()
424  {
425  return $this->getImagePathFs() . $this->getContent();
426  }
427 
428  protected function getImageFileUrl()
429  {
430  return $this->getImagePathWeb() . $this->getContent();
431  }
432 
433  public function getPresentationImageUrl()
434  {
435  if( $this->thumbnailFileExists() )
436  {
437  return $this->getThumbnailFileUrl();
438  }
439 
440  if( $this->imageFileExists() )
441  {
442  return $this->getImageFileUrl();
443  }
444 
445  return '';
446  }
447 
448  public function getExportIdent()
449  {
450  $ident = array(
451  $this->getRandomIdentifier(),
452  $this->getSolutionIdentifier(),
453  $this->getPosition(),
454  $this->getIndentation()
455  );
456 
457  return implode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
458  }
459 
460  public function isExportIdent($ident)
461  {
462  if( !strlen($ident) )
463  {
464  return false;
465  }
466 
467  $parts = explode(self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident);
468 
469  if( count($parts) != 4 )
470  {
471  return false;
472  }
473 
475  {
476  return false;
477  }
478 
480  {
481  return false;
482  }
483 
485  {
486  return false;
487  }
488 
490  {
491  return false;
492  }
493 
494  return true;
495  }
496 
497  public function setExportIdent($ident)
498  {
499  if( $this->isExportIdent($ident) )
500  {
501  list($randomId, $solutionId, $pos, $indent) = explode(
502  self::EXPORT_IDENT_PROPERTY_SEPARATOR, $ident
503  );
504 
505  $this->setRandomIdentifier($randomId);
506  $this->setSolutionIdentifier($solutionId);
507  $this->setPosition($pos);
508  $this->setIndentation($indent);
509  }
510  }
511 }
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