ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 174 of file class.ilAssOrderingFormValuesObjectsConverter.php.

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

Referenced by manipulateFormInputValues().

175  {
176  $values = array();
177 
178  foreach ($elements as $identifier => $orderingElement) {
179  switch ($this->getContext()) {
180  case self::CONTEXT_MAINTAIN_ELEMENT_TEXT:
181 
182  $values[$identifier] = $this->getTextContentValueFromObject($orderingElement);
183  break;
184 
185  case self::CONTEXT_MAINTAIN_ELEMENT_IMAGE:
186 
187  $values[$identifier] = $this->getImageContentValueFromObject($orderingElement);
188  break;
189 
190  case self::CONTEXT_MAINTAIN_HIERARCHY:
191 
192  $values[$identifier] = $this->getStructValueFromObject($orderingElement);
193  break;
194 
195  default:
196  throw new ilFormException('unsupported context: ' . $this->getContext());
197  }
198  }
199 
200  return $values;
201  }
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 249 of file class.ilAssOrderingFormValuesObjectsConverter.php.

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

Referenced by manipulateFormSubmitValues().

250  {
251  $elements = array();
252 
253  $position = 0;
254 
255  foreach ($values as $identifier => $value) {
256  $element = new ilAssOrderingElement();
257  $element->setRandomIdentifier($identifier);
258 
259  $element->setPosition($position++);
260 
261  if ($this->getContext() == self::CONTEXT_MAINTAIN_HIERARCHY) {
262  $element->setIndentation($value);
263  } else {
264  $element->setContent($value);
265  }
266 
267  if ($this->getContext() == self::CONTEXT_MAINTAIN_ELEMENT_IMAGE) {
268  $element->setUploadImageName($this->fetchSubmittedImageFilename($identifier));
269  $element->setUploadImageFile($this->fetchSubmittedUploadFilename($identifier));
270 
271  $element->setImageRemovalRequest($this->wasImageRemovalRequested($identifier));
272  }
273 
274  $elements[$identifier] = $element;
275  }
276 
277  return $elements;
278  }
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 301 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and fetchSubmittedUploadFiles().

Referenced by fetchSubmittedImageFilename(), and fetchSubmittedUploadFilename().

302  {
303  $uploadFiles = $this->fetchSubmittedUploadFiles();
304 
305  if (!isset($uploadFiles[$identifier])) {
306  return array();
307  }
308 
309  return $uploadFiles[$identifier];
310  }
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 292 of file class.ilAssOrderingFormValuesObjectsConverter.php.

Referenced by fetchSubmittedImageFilename(), and fetchSubmittedUploadFilename().

293  {
294  if (!isset($fileUpload[$property]) || !strlen($fileUpload[$property])) {
295  return null;
296  }
297 
298  return $fileUpload[$property];
299  }
+ Here is the caller graph for this function:

◆ fetchSubmittedImageFilename()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedImageFilename (   $identifier)
protected

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

References fetchElementFileUpload(), and fetchSubmittedFileUploadProperty().

Referenced by constructElementsFromValues().

281  {
282  $fileUpload = $this->fetchElementFileUpload($identifier);
283  return $this->fetchSubmittedFileUploadProperty($fileUpload, 'name');
284  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchSubmittedUploadFilename()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedUploadFilename (   $identifier)
protected

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

References fetchElementFileUpload(), and fetchSubmittedFileUploadProperty().

Referenced by constructElementsFromValues().

287  {
288  $fileUpload = $this->fetchElementFileUpload($identifier);
289  return $this->fetchSubmittedFileUploadProperty($fileUpload, 'tmp_name');
290  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchSubmittedUploadFiles()

ilAssOrderingFormValuesObjectsConverter::fetchSubmittedUploadFiles ( )
protected

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

References getFileSubmitDataRestructuredByIdentifiers().

Referenced by fetchElementFileUpload().

313  {
314  $submittedUploadFiles = $this->getFileSubmitDataRestructuredByIdentifiers();
315  //$submittedUploadFiles = $this->getFileSubmitsHavingActualUpload($submittedUploadFiles);
316  return $submittedUploadFiles;
317  }
+ 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 361 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and getPostVar().

Referenced by getFileSubmitDataRestructuredByIdentifiers().

362  {
363  if (!isset($_FILES[$this->getPostVar()])) {
364  return array();
365  }
366 
367  return $_FILES[$this->getPostVar()];
368  }
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 344 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References array, and getFileSubmitData().

Referenced by fetchSubmittedUploadFiles().

345  {
346  $submittedUploadFiles = array();
347 
348  foreach ($this->getFileSubmitData() as $uploadProperty => $valueElement) {
349  foreach ($valueElement as $elementIdentifier => $uploadValue) {
350  if (!isset($submittedUploadFiles[$elementIdentifier])) {
351  $submittedUploadFiles[$elementIdentifier] = array();
352  }
353 
354  $submittedUploadFiles[$elementIdentifier][$uploadProperty] = $uploadValue;
355  }
356  }
357 
358  return $submittedUploadFiles;
359  }
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 319 of file class.ilAssOrderingFormValuesObjectsConverter.php.

320  {
321  foreach ($submittedUploadFiles as $identifier => $uploadProperties) {
322  if (!isset($uploadProperties['tmp_name'])) {
323  unset($submittedUploadFiles[$identifier]);
324  continue;
325  }
326 
327  if (!strlen($uploadProperties['tmp_name'])) {
328  unset($submittedUploadFiles[$identifier]);
329  continue;
330  }
331 
332  if (!is_uploaded_file($uploadProperties['tmp_name'])) {
333  unset($submittedUploadFiles[$identifier]);
334  continue;
335  }
336  }
337 
338  return $submittedUploadFiles;
339  }

◆ getImageContentValueFromObject()

ilAssOrderingFormValuesObjectsConverter::getImageContentValueFromObject ( ilAssOrderingElement  $element)
protected

Definition at line 208 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 220 of file class.ilAssOrderingFormValuesObjectsConverter.php.

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

Referenced by collectValuesFromElements().

221  {
222  return array(
223  'answer_id' => $element->getId(),
224  'random_id' => $element->getRandomIdentifier(),
225  'content' => (string) $element->getContent(),
226  'ordering_position' => $element->getPosition(),
227  'ordering_indentation' => $element->getIndentation()
228  );
229  }
Add rich text string
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 203 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References ilAssOrderingElement\getContent().

Referenced by collectValuesFromElements().

204  {
205  return $element->getContent();
206  }
+ 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 165 of file class.ilAssOrderingFormValuesObjectsConverter.php.

References collectValuesFromElements(), and needsConvertToValues().

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

◆ manipulateFormSubmitValues()

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

Implements ilFormValuesManipulator.

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

References constructElementsFromValues(), and needsConvertToElements().

241  {
242  if ($this->needsConvertToElements($valuesOrElements)) {
243  $valuesOrElements = $this->constructElementsFromValues($valuesOrElements);
244  }
245 
246  return $valuesOrElements;
247  }
+ Here is the call graph for this function:

◆ needsConvertToElements()

ilAssOrderingFormValuesObjectsConverter::needsConvertToElements (   $valuesOrElements)
protected

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

Referenced by manipulateFormSubmitValues().

232  {
233  if (!count($valuesOrElements)) {
234  return false;
235  }
236 
237  return !(current($valuesOrElements) instanceof ilAssOrderingElement);
238  }
+ 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  return false;
160  }
161 
162  return (current($elementsOrValues) instanceof ilAssOrderingElement);
163  }
+ 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 370 of file class.ilAssOrderingFormValuesObjectsConverter.php.

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

Referenced by constructElementsFromValues().

371  {
372  if (!$this->getImageRemovalCommand()) {
373  return false;
374  }
375 
376  if (!isset($_POST['cmd']) || !is_array($_POST['cmd'])) {
377  return false;
378  }
379 
380  $cmdArr = $_POST['cmd'];
381 
382  if (!isset($cmdArr[$this->getImageRemovalCommand()])) {
383  return false;
384  }
385 
386  $fieldArr = $cmdArr[$this->getImageRemovalCommand()];
387 
388  if (!isset($fieldArr[$this->getPostVar()])) {
389  return false;
390  }
391 
392  $identifierArr = $fieldArr[$this->getPostVar()];
393 
394  return key($identifierArr) == $identifier;
395  }
$_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: