ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestExportFilename.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Component/classes/class.ilPlugin.php';
5 
12 {
16  protected $test;
17 
21  protected $timestamp = 0;
22 
26  public function __construct(ilObjTest $test)
27  {
28  $this->test = $test;
29  $this->timestamp = time();
30  }
31 
35  public function getTimestamp()
36  {
37  return $this->timestamp;
38  }
39 
46  public function getPathname($extension, $additional = '')
47  {
48  if (!is_string($extension) || !strlen($extension)) {
49  throw new ilException('Missing file extension! Please pass a file extension of type string.');
50  } elseif (substr_count($extension, '.') > 1 || (strpos($extension, '.') !== false && strpos($extension, '.') !== 0)) {
51  throw new ilException('Please use at most one dot in your file extension.');
52  } elseif (strpos($extension, '.') === 0) {
53  $extension = substr($extension, 1);
54  }
55 
56  if (!is_string($additional)) {
57  } elseif (strlen($additional)) {
58  if (strpos($additional, '__') === 0) {
59  throw new ilException('The additional file part may not contain __ at the beginning!');
60  }
61 
62  $additional = '__' . $additional . '_';
63  } else {
64  $additional = '_';
65  }
66 
67  return $this->test->getExportDirectory() . DIRECTORY_SEPARATOR . $this->getTimestamp() . '__' . IL_INST_ID . '__' . $this->test->getType() . $additional . $this->test->getId() . '.' . $extension;
68  }
69 }
test()
Definition: build.php:107
$additional
Definition: goto.php:50
getPathname($extension, $additional='')