ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAssOrderingFormValuesObjectsConverter Class Reference
+ Inheritance diagram for ilAssOrderingFormValuesObjectsConverter:
+ Collaboration diagram for ilAssOrderingFormValuesObjectsConverter:

Public Member Functions

 getContext ()
 
 setContext ($context)
 
 getPostVar ()
 
 setPostVar ($postVar)
 
 getImageRemovalCommand ()
 
 setImageRemovalCommand ($imageRemovalCommand)
 
 getImageUrlPath ()
 
 setImageUrlPath ($imageUrlPath)
 
 getImageFsPath ()
 
 setImageFsPath ($imageFsPath)
 
 getThumbnailPrefix ()
 
 setThumbnailPrefix ($thumbnailPrefix)
 
 getIndentationsPostVar ()
 
 manipulateFormInputValues ($elementsOrValues)
 
 manipulateFormSubmitValues ($valuesOrElements)
 
 constructElementsFromValues (array $values)
 

Data Fields

const INDENTATIONS_POSTVAR_SUFFIX = '_ordering'
 
const INDENTATIONS_POSTVAR_SUFFIX_JS = '__default'
 
const CONTEXT_MAINTAIN_ELEMENT_TEXT = 'maintainItemText'
 
const CONTEXT_MAINTAIN_ELEMENT_IMAGE = 'maintainItemImage'
 
const CONTEXT_MAINTAIN_HIERARCHY = 'maintainHierarchy'
 

Protected Member Functions

 needsConvertToValues ($elementsOrValues)
 
 collectValuesFromElements (array $elements)
 
 getTextContentValueFromObject (ilAssOrderingElement $element)
 
 getImageContentValueFromObject (ilAssOrderingElement $element)
 
 getStructValueFromObject (ilAssOrderingElement $element)
 
 needsConvertToElements ($valuesOrElements)
 
 fetchSubmittedImageFilename ($identifier)
 
 fetchSubmittedUploadFilename ($identifier)
 
 fetchSubmittedFileUploadProperty ($fileUpload, $property)
 
 fetchElementFileUpload ($identifier)
 
 fetchSubmittedUploadFiles ()
 
 getFileSubmitsHavingActualUpload ($submittedUploadFiles)
 
 getFileSubmitDataRestructuredByIdentifiers ()
 
 getFileSubmitData ()
 
 wasImageRemovalRequested ($identifier)
 

Protected Attributes

 $context = null
 
 $postVar = null
 
 $imageRemovalCommand = null
 
 $imageUrlPath
 
 $imageFsPath
 
 $thumbnailPrefix
 

Detailed Description

Member Function Documentation

◆ collectValuesFromElements()

ilAssOrderingFormValuesObjectsConverter::collectValuesFromElements ( array  $elements)
protected

Definition at line 176 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, getContext(), getImageContentValueFromObject(), getStructValueFromObject(), and getTextContentValueFromObject().

Referenced by manipulateFormInputValues().

177  {
178  $values = array();
179 
180  foreach($elements as $identifier => $orderingElement)
181  {
182  switch( $this->getContext() )
183  {
184  case self::CONTEXT_MAINTAIN_ELEMENT_TEXT:
185 
186  $values[$identifier] = $this->getTextContentValueFromObject($orderingElement);
187  break;
188 
189  case self::CONTEXT_MAINTAIN_ELEMENT_IMAGE:
190 
191  $values[$identifier] = $this->getImageContentValueFromObject($orderingElement);
192  break;
193 
194  case self::CONTEXT_MAINTAIN_HIERARCHY:
195 
196  $values[$identifier] = $this->getStructValueFromObject($orderingElement);
197  break;
198 
199  default:
200  throw new ilFormException('unsupported context: '.$this->getContext());
201  }
202  }
203 
204  return $values;
205  }
Class ilFormException.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constructElementsFromValues()

ilAssOrderingFormValuesObjectsConverter::constructElementsFromValues ( array  $values)

Definition at line 255 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, fetchSubmittedImageFilename(), fetchSubmittedUploadFilename(), getContext(), and wasImageRemovalRequested().

Referenced by manipulateFormSubmitValues().

256  {
257  $elements = array();
258 
259  $position = 0;
260 
261  foreach($values as $identifier => $value)
262  {
263  $element = new ilAssOrderingElement();
264  $element->setRandomIdentifier($identifier);
265 
266  $element->setPosition($position++);
267 
268  if( $this->getContext() == self::CONTEXT_MAINTAIN_HIERARCHY )
269  {
270  $element->setIndentation($value);
271  }
272  else
273  {
274  $element->setContent($value);
275  }
276 
277  if( $this->getContext() == self::CONTEXT_MAINTAIN_ELEMENT_IMAGE )
278  {
279  $element->setUploadImageName($this->fetchSubmittedImageFilename($identifier));
280  $element->setUploadImageFile($this->fetchSubmittedUploadFilename($identifier));
281 
282  $element->setImageRemovalRequest($this->wasImageRemovalRequested($identifier));
283  }
284 
285  $elements[$identifier] = $element;
286  }
287 
288  return $elements;
289  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchElementFileUpload()

ilAssOrderingFormValuesObjectsConverter::fetchElementFileUpload (   $identifier)
protected

Definition at line 313 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and fetchSubmittedUploadFiles().

Referenced by fetchSubmittedImageFilename(), and fetchSubmittedUploadFilename().

314  {
315  $uploadFiles = $this->fetchSubmittedUploadFiles();
316 
317  if( !isset($uploadFiles[$identifier]) )
318  {
319  return array();
320  }
321 
322  return $uploadFiles[$identifier];
323  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchSubmittedFileUploadProperty()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedFileUploadProperty (   $fileUpload,
  $property 
)
protected

Definition at line 303 of file class.ilAssOrderingFormValuesObjectsConverter.php.

Referenced by fetchSubmittedImageFilename(), and fetchSubmittedUploadFilename().

304  {
305  if( !isset($fileUpload[$property]) || !strlen($fileUpload[$property]) )
306  {
307  return null;
308  }
309 
310  return $fileUpload[$property];
311  }
+ Here is the caller graph for this function:

◆ fetchSubmittedImageFilename()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedImageFilename (   $identifier)
protected

Definition at line 291 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References fetchElementFileUpload(), and fetchSubmittedFileUploadProperty().

Referenced by constructElementsFromValues().

292  {
293  $fileUpload = $this->fetchElementFileUpload($identifier);
294  return $this->fetchSubmittedFileUploadProperty($fileUpload, 'name');
295  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchSubmittedUploadFilename()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedUploadFilename (   $identifier)
protected

Definition at line 297 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References fetchElementFileUpload(), and fetchSubmittedFileUploadProperty().

Referenced by constructElementsFromValues().

298  {
299  $fileUpload = $this->fetchElementFileUpload($identifier);
300  return $this->fetchSubmittedFileUploadProperty($fileUpload, 'tmp_name');
301  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchSubmittedUploadFiles()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedUploadFiles ( )
protected

Definition at line 325 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References getFileSubmitDataRestructuredByIdentifiers().

Referenced by fetchElementFileUpload().

326  {
327  $submittedUploadFiles = $this->getFileSubmitDataRestructuredByIdentifiers();
328  //$submittedUploadFiles = $this->getFileSubmitsHavingActualUpload($submittedUploadFiles);
329  return $submittedUploadFiles;
330  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContext()

ilAssOrderingFormValuesObjectsConverter::getContext ( )
Returns
string

Definition at line 54 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $context.

Referenced by collectValuesFromElements(), and constructElementsFromValues().

+ Here is the caller graph for this function:

◆ getFileSubmitData()

ilAssOrderingFormValuesObjectsConverter::getFileSubmitData ( )
protected

Definition at line 381 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and getPostVar().

Referenced by getFileSubmitDataRestructuredByIdentifiers().

382  {
383  if( !isset($_FILES[$this->getPostVar()]) )
384  {
385  return array();
386  }
387 
388  return $_FILES[$this->getPostVar()];
389  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileSubmitDataRestructuredByIdentifiers()

ilAssOrderingFormValuesObjectsConverter::getFileSubmitDataRestructuredByIdentifiers ( )
protected
Returns
array

Definition at line 361 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and getFileSubmitData().

Referenced by fetchSubmittedUploadFiles().

362  {
363  $submittedUploadFiles = array();
364 
365  foreach( $this->getFileSubmitData() as $uploadProperty => $valueElement )
366  {
367  foreach( $valueElement as $elementIdentifier => $uploadValue )
368  {
369  if( !isset( $submittedUploadFiles[$elementIdentifier] ) )
370  {
371  $submittedUploadFiles[$elementIdentifier] = array();
372  }
373 
374  $submittedUploadFiles[$elementIdentifier][$uploadProperty] = $uploadValue;
375  }
376  }
377 
378  return $submittedUploadFiles;
379  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileSubmitsHavingActualUpload()

ilAssOrderingFormValuesObjectsConverter::getFileSubmitsHavingActualUpload (   $submittedUploadFiles)
protected

Definition at line 332 of file class.ilAssOrderingFormValuesObjectsConverter.php.

333  {
334  foreach($submittedUploadFiles as $identifier => $uploadProperties)
335  {
336  if( !isset($uploadProperties['tmp_name']) )
337  {
338  unset($submittedUploadFiles[$identifier]);
339  continue;
340  }
341 
342  if( !strlen($uploadProperties['tmp_name']) )
343  {
344  unset($submittedUploadFiles[$identifier]);
345  continue;
346  }
347 
348  if( !is_uploaded_file($uploadProperties['tmp_name']) )
349  {
350  unset($submittedUploadFiles[$identifier]);
351  continue;
352  }
353  }
354 
355  return $submittedUploadFiles;
356  }

◆ getImageContentValueFromObject()

ilAssOrderingFormValuesObjectsConverter::getImageContentValueFromObject ( ilAssOrderingElement  $element)
protected

Definition at line 212 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, ilAssOrderingElement\getContent(), getImageFsPath(), getImageUrlPath(), ilAssOrderingElement\getPresentationImageUrl(), getThumbnailPrefix(), ilAssOrderingElement\setImagePathFs(), ilAssOrderingElement\setImagePathWeb(), and ilAssOrderingElement\setImageThumbnailPrefix().

Referenced by collectValuesFromElements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageFsPath()

ilAssOrderingFormValuesObjectsConverter::getImageFsPath ( )
Returns
string

Definition at line 118 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageFsPath.

Referenced by getImageContentValueFromObject().

+ Here is the caller graph for this function:

◆ getImageRemovalCommand()

ilAssOrderingFormValuesObjectsConverter::getImageRemovalCommand ( )
Returns
null

Definition at line 86 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageRemovalCommand.

Referenced by wasImageRemovalRequested().

+ Here is the caller graph for this function:

◆ getImageUrlPath()

ilAssOrderingFormValuesObjectsConverter::getImageUrlPath ( )
Returns
string

Definition at line 102 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageUrlPath.

Referenced by getImageContentValueFromObject().

+ Here is the caller graph for this function:

◆ getIndentationsPostVar()

ilAssOrderingFormValuesObjectsConverter::getIndentationsPostVar ( )

Definition at line 147 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $postVar, and getPostVar().

148  {
149  $postVar = $this->getPostVar();
150  $postVar .= self::INDENTATIONS_POSTVAR_SUFFIX;
151  $postVar .= self::INDENTATIONS_POSTVAR_SUFFIX_JS;
152 
153  return $postVar;
154  }
+ Here is the call graph for this function:

◆ getPostVar()

ilAssOrderingFormValuesObjectsConverter::getPostVar ( )
Returns
string

Definition at line 70 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $postVar.

Referenced by getFileSubmitData(), getIndentationsPostVar(), and wasImageRemovalRequested().

+ Here is the caller graph for this function:

◆ getStructValueFromObject()

ilAssOrderingFormValuesObjectsConverter::getStructValueFromObject ( ilAssOrderingElement  $element)
protected

Definition at line 224 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, ilAssOrderingElement\getContent(), ilAssOrderingElement\getId(), ilAssOrderingElement\getIndentation(), ilAssOrderingElement\getPosition(), ilAssOrderingElement\getRandomIdentifier(), and string.

Referenced by collectValuesFromElements().

225  {
226  return array(
227  'answer_id' => $element->getId(),
228  'random_id' => $element->getRandomIdentifier(),
229  'content' => (string)$element->getContent(),
230  'ordering_position' => $element->getPosition(),
231  'ordering_indentation' => $element->getIndentation()
232  );
233  }
Add rich text string
The name of the decorator.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextContentValueFromObject()

ilAssOrderingFormValuesObjectsConverter::getTextContentValueFromObject ( ilAssOrderingElement  $element)
protected

Definition at line 207 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References ilAssOrderingElement\getContent().

Referenced by collectValuesFromElements().

208  {
209  return $element->getContent();
210  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThumbnailPrefix()

ilAssOrderingFormValuesObjectsConverter::getThumbnailPrefix ( )
Returns
string

Definition at line 134 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $thumbnailPrefix.

Referenced by getImageContentValueFromObject().

+ Here is the caller graph for this function:

◆ manipulateFormInputValues()

ilAssOrderingFormValuesObjectsConverter::manipulateFormInputValues (   $inputValues)
Parameters
array$inputValues
Returns
array $inputValues

Implements ilFormValuesManipulator.

Definition at line 166 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References collectValuesFromElements(), and needsConvertToValues().

167  {
168  if( $this->needsConvertToValues($elementsOrValues) )
169  {
170  $elementsOrValues = $this->collectValuesFromElements($elementsOrValues);
171  }
172 
173  return $elementsOrValues;
174  }
+ Here is the call graph for this function:

◆ manipulateFormSubmitValues()

ilAssOrderingFormValuesObjectsConverter::manipulateFormSubmitValues (   $submitValues)
Parameters
array$submitValues
Returns
array $submitValues

Implements ilFormValuesManipulator.

Definition at line 245 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References constructElementsFromValues(), and needsConvertToElements().

246  {
247  if( $this->needsConvertToElements($valuesOrElements) )
248  {
249  $valuesOrElements = $this->constructElementsFromValues($valuesOrElements);
250  }
251 
252  return $valuesOrElements;
253  }
+ Here is the call graph for this function:

◆ needsConvertToElements()

ilAssOrderingFormValuesObjectsConverter::needsConvertToElements (   $valuesOrElements)
protected

Definition at line 235 of file class.ilAssOrderingFormValuesObjectsConverter.php.

Referenced by manipulateFormSubmitValues().

236  {
237  if( !count($valuesOrElements) )
238  {
239  return false;
240  }
241 
242  return !( current($valuesOrElements) instanceof ilAssOrderingElement );
243  }
+ Here is the caller graph for this function:

◆ needsConvertToValues()

ilAssOrderingFormValuesObjectsConverter::needsConvertToValues (   $elementsOrValues)
protected

Definition at line 156 of file class.ilAssOrderingFormValuesObjectsConverter.php.

Referenced by manipulateFormInputValues().

157  {
158  if( !count($elementsOrValues) )
159  {
160  return false;
161  }
162 
163  return ( current($elementsOrValues) instanceof ilAssOrderingElement );
164  }
+ Here is the caller graph for this function:

◆ setContext()

ilAssOrderingFormValuesObjectsConverter::setContext (   $context)
Parameters
$context

Definition at line 62 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $context.

◆ setImageFsPath()

ilAssOrderingFormValuesObjectsConverter::setImageFsPath (   $imageFsPath)
Parameters
string$imageFsPath

Definition at line 126 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageFsPath.

◆ setImageRemovalCommand()

ilAssOrderingFormValuesObjectsConverter::setImageRemovalCommand (   $imageRemovalCommand)
Parameters
null$imageRemovalCommand

Definition at line 94 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageRemovalCommand.

◆ setImageUrlPath()

ilAssOrderingFormValuesObjectsConverter::setImageUrlPath (   $imageUrlPath)
Parameters
string$imageUrlPath

Definition at line 110 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $imageUrlPath.

◆ setPostVar()

ilAssOrderingFormValuesObjectsConverter::setPostVar (   $postVar)
Parameters
$postVar

Definition at line 78 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $postVar.

◆ setThumbnailPrefix()

ilAssOrderingFormValuesObjectsConverter::setThumbnailPrefix (   $thumbnailPrefix)
Parameters
string$thumbnailPrefix

Definition at line 142 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $thumbnailPrefix.

◆ wasImageRemovalRequested()

ilAssOrderingFormValuesObjectsConverter::wasImageRemovalRequested (   $identifier)
protected

Definition at line 391 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References $_POST, getImageRemovalCommand(), and getPostVar().

Referenced by constructElementsFromValues().

392  {
393  if( !$this->getImageRemovalCommand() )
394  {
395  return false;
396  }
397 
398  if( !isset($_POST['cmd']) || !is_array($_POST['cmd']) )
399  {
400  return false;
401  }
402 
403  $cmdArr = $_POST['cmd'];
404 
405  if( !isset($cmdArr[$this->getImageRemovalCommand()]) )
406  {
407  return false;
408  }
409 
410  $fieldArr = $cmdArr[$this->getImageRemovalCommand()];
411 
412  if( !isset($fieldArr[$this->getPostVar()]) )
413  {
414  return false;
415  }
416 
417  $identifierArr = $fieldArr[$this->getPostVar()];
418 
419  return key($identifierArr) == $identifier;
420  }
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $context

ilAssOrderingFormValuesObjectsConverter::$context = null
protected

Definition at line 24 of file class.ilAssOrderingFormValuesObjectsConverter.php.

Referenced by getContext(), and setContext().

◆ $imageFsPath

ilAssOrderingFormValuesObjectsConverter::$imageFsPath
protected

◆ $imageRemovalCommand

ilAssOrderingFormValuesObjectsConverter::$imageRemovalCommand = null
protected

◆ $imageUrlPath

ilAssOrderingFormValuesObjectsConverter::$imageUrlPath
protected

◆ $postVar

ilAssOrderingFormValuesObjectsConverter::$postVar = null
protected

◆ $thumbnailPrefix

ilAssOrderingFormValuesObjectsConverter::$thumbnailPrefix
protected

◆ CONTEXT_MAINTAIN_ELEMENT_IMAGE

const ilAssOrderingFormValuesObjectsConverter::CONTEXT_MAINTAIN_ELEMENT_IMAGE = 'maintainItemImage'

◆ CONTEXT_MAINTAIN_ELEMENT_TEXT

const ilAssOrderingFormValuesObjectsConverter::CONTEXT_MAINTAIN_ELEMENT_TEXT = 'maintainItemText'

◆ CONTEXT_MAINTAIN_HIERARCHY

const ilAssOrderingFormValuesObjectsConverter::CONTEXT_MAINTAIN_HIERARCHY = 'maintainHierarchy'

◆ INDENTATIONS_POSTVAR_SUFFIX

const ilAssOrderingFormValuesObjectsConverter::INDENTATIONS_POSTVAR_SUFFIX = '_ordering'

◆ INDENTATIONS_POSTVAR_SUFFIX_JS

const ilAssOrderingFormValuesObjectsConverter::INDENTATIONS_POSTVAR_SUFFIX_JS = '__default'

The documentation for this class was generated from the following file: