本文整理汇总了PHP中Reference::createReference方法的典型用法代码示例。如果您正苦于以下问题:PHP Reference::createReference方法的具体用法?PHP Reference::createReference怎么用?PHP Reference::createReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reference
的用法示例。
在下文中一共展示了Reference::createReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
Authentication::checkRights(PRIVILEGE_LEVEL::TUTOR, $cid, $uid, $globalUserData);
$langTemplate = 'TutorUpload_Controller';
Language::loadLanguageFile('de', $langTemplate, 'json', dirname(__FILE__) . '/');
if (isset($_POST['action']) && $_POST['action'] == 'TutorUpload') {
if (isset($_FILES['MarkingFile'])) {
$file = $_FILES['MarkingFile'];
$error = $file['error'];
if ($error == 0) {
$filePath = $file['tmp_name'];
$displayName = $file['name'];
$type = $file["type"];
// checks file ending
if (MimeReader::get_mime($filePath) == "application/zip") {
// creates the JSON object containing the file
$file = new File();
$file->setBody(Reference::createReference($filePath));
$file->setTimeStamp(time());
$file->setDisplayName($displayName);
$file = File::encodeFile($file);
// sends the JSON object to the logic
$URI = $logicURI . "/tutor/user/{$uid}/course/{$cid}";
$error = http_post_data($URI, $file, true, $message);
if ($message == "201" || $message == "200") {
$successmsg = Language::Get('main', 'sucessFileUpload', $langTemplate);
$notifications[] = MakeNotification('success', $successmsg);
} else {
$errors = @json_decode($error);
if ($errors !== null) {
foreach ($errors as $err) {
$notifications[] = MakeNotification('error', $err);
}
示例2:
$error = -1;
}
}
} else {
$file = null;
$error = 0;
}
if ($error === 0) {
$errormsg = '';
// prüfe ob nur erlaubte Zeichen im Dateinamen verwendet wurden
$pregRes = @preg_match("%^((?!\\.)[a-zA-Z0-9\\.\\-_]+)\$%", $file['name']);
if ($file === null || $pregRes) {
if (isset($_FILES[$fileName])) {
$filePath = $file['tmp_name'];
$uploadFile = File::createFile(null, $file['name'], null, $timestamp, null, null);
$uploadFile->setBody(Reference::createReference($file['tmp_name']));
} else {
$uploadFile = File::createFile(null, null, null, $timestamp, null, null);
$uploadFile->setBody(Form::encodeForm($formdata), true);
}
$uploadSubmission = Submission::createSubmission(null, $uid, null, $exerciseId, $exercise['comment'], 1, $timestamp, null, $leaderId);
$uploadSubmission->setFile($uploadFile);
$uploadSubmission->setExerciseName(isset($exercise['name']) ? $exercise['name'] : null);
$uploadSubmission->setSelectedForGroup('1');
if ($isExpired) {
$uploadSubmission->setAccepted(0);
}
$URL = $serverURI . '/logic/LProcessor/submission';
///echo Submission::encodeSubmission($uploadSubmission);return;
$result = http_post_data($URL, Submission::encodeSubmission($uploadSubmission), true, $message);
//echo $result;
示例3: uploadZip
public function uploadZip($userid, $courseid)
{
// error array of strings
$errors = array();
LTutor::generatepath($this->config['DIR']['temp']);
$tempDir = $this->tempdir($this->config['DIR']['temp'], 'extractZip', $mode = 0775);
$body = File::decodeFile($this->app->request->getBody());
//1 file-Object
$filename = $tempDir . '/' . $courseid . '.zip';
file_put_contents($filename, $body->getBody(true));
unset($body);
$zip = new ZipArchive();
$zip->open($filename);
$zip->extractTo($tempDir . '/files');
$zip->close();
unlink($filename);
///$this->deleteDir(dirname($filename));
unset($zip);
$files = $tempDir . '/files';
// check if csv file exists
if (file_exists($files . '/Liste.csv')) {
$csv = fopen($files . '/Liste.csv', "r");
if (($transactionId = fgetcsv($csv, 0, ';')) === false) {
fclose($csv);
$this->deleteDir($tempDir);
$this->app->response->setStatus(409);
$errors[] = 'empty .csv file';
$this->app->response->setBody(json_encode($errors));
$this->app->stop();
}
$result = Request::routeRequest('GET', '/transaction/authentication/TutorCSV_' . $userid . '_' . $courseid . '/transaction/' . $transactionId[0], array(), '', $this->_getTransaction, 'transaction');
if (isset($result['status']) && $result['status'] == 200 && isset($result['content'])) {
$transaction = Transaction::decodeTransaction($result['content']);
$transaction = json_decode($transaction->getContent(), true);
unset($result);
$defaultOrder = array('ID', 'NAME', 'USERNAME', 'POINTS', 'MAXPOINTS', 'OUTSTANDING', 'STATUS', 'TUTORCOMMENT', 'STUDENTCOMMENT', 'FILE');
$currectOrder = $defaultOrder;
$markings = array();
while (($row = fgetcsv($csv, 0, ';')) !== false) {
if (substr($row[0], 0, 2) == '--') {
$row[0] = substr($row[0], 2);
if (in_array(strtoupper($row[0]), $defaultOrder)) {
$currectOrder = array();
foreach ($row as $ro) {
$currectOrder[strtoupper($ro)] = count($currectOrder);
}
}
} elseif (implode('', $row) != '' && substr($row[0], 0, 2) != '--') {
if (isset($currectOrder['ID']) && !isset($row[$currectOrder['ID']]) || isset($currectOrder['POINTS']) && !isset($row[$currectOrder['POINTS']]) || isset($currectOrder['FILE']) && !isset($row[$currectOrder['FILE']]) || isset($currectOrder['TUTORCOMMENT']) && !isset($row[$currectOrder['TUTORCOMMENT']]) || isset($currectOrder['OUTSTANDING']) && !isset($row[$currectOrder['OUTSTANDING']]) || isset($currectOrder['STATUS']) && !isset($row[$currectOrder['STATUS']])) {
$errors[] = 'invalid Liste.csv';
fclose($csv);
$this->deleteDir($tempDir);
$this->app->response->setStatus(409);
$this->app->response->setBody(json_encode($errors));
$this->app->stop();
}
$markingId = isset($currectOrder['ID']) ? $row[$currectOrder['ID']] : null;
$points = isset($currectOrder['POINTS']) ? $row[$currectOrder['POINTS']] : null;
$points = str_replace(',', '.', $points);
$markingFile = isset($currectOrder['FILE']) ? $row[$currectOrder['FILE']] : null;
// check if markingId exists in transaction
if (!isset($transaction['markings'][$markingId])) {
// unknown markingId
fclose($csv);
$this->deleteDir($tempDir);
$this->app->response->setStatus(409);
$errors[] = "unknown ID: {$markingId}";
$this->app->response->setBody(json_encode($errors));
$this->app->stop();
}
///var_dump($transaction['markings'][$markingId]);
$markingData = $transaction['markings'][$markingId];
// checks whether the points are less or equal to the maximum points
if ($points > $markingData['maxPoints'] || $points < 0) {
// too much points
///fclose($csv);
///$this->deleteDir($tempDir);
///$this->app->response->setStatus(409);
///$errors[] = "incorrect points in marking: {$markingId}";
///$this->app->response->setBody(json_encode($errors));
///$this->app->stop();
}
// checks if file with this markingid exists
if ($markingFile == null || $markingFile == '' || file_exists($files . '/' . $markingFile)) {
if ($markingFile != '' && $markingFile != null) {
$fileAddress = $files . '/' . $markingFile;
///file_get_contents($files.'/'.$markingFile);
// file
$fileInfo = pathinfo($markingFile);
$file = new File();
$file->setDisplayName($fileInfo['basename']);
$file->setBody(Reference::createReference($fileAddress));
} else {
$file = null;
}
if (isset($transaction['markings'][$markingId]['submissionId']) && $transaction['markings'][$markingId]['submissionId'] < 0) {
// create new submission object
$submissionId = $transaction['markings'][$markingId]['submissionId'];
$studentId = $transaction['markings'][$markingId]['studentId'];
$exerciseId = $transaction['markings'][$markingId]['exerciseId'];
//.........这里部分代码省略.........
示例4: Reference
if (Reference::isValidResults($file)) {
$reference = new Reference($file);
$referenceInfo = $reference->getInfo();
$referenceInfo['href'] = $app->urlFor('references', array('id' => $file));
array_push($references, $referenceInfo);
}
}
closedir($dh);
}
sort($references);
$app->render(200, array('references' => $references));
})->name('referenceIndex');
$app->post('/', function () use($app) {
global $status, $statusModified;
// Create a new session
$reference = Reference::createReference($status['reference'], $app->request()->params('sessions'), $app->request()->params('name'), $app->request()->params('minPass'));
$status['reference']++;
$statusModified = true;
$referenceInfo = $reference->getInfo();
$referenceInfo['href'] = $app->urlFor('references', array('id' => $referenceInfo['id']));
Notify(ADMIN_TOPIC, array('action' => 'create', 'reference' => $referenceInfo));
$app->render(200, array('reference' => $referenceInfo));
});
$app->get('/:id', function ($id) use($app) {
$reference = new Reference($id);
$download = $app->request()->params('download');
if (null != $download && $download) {
header("Content-Disposition: attachment; filename=\"reference-{$id}.json\"");
}
$app->render(200, $reference->GetResults($app->request()->params('filters'), $app->request()->params('pageIndex'), $app->request()->params('pageSize')));
})->name('references');
示例5: Process
$processor = new Process();
$processor->setExercise(Exercise::decodeExercise(json_encode($subexercise)));
$component = new Component();
$component->setId($Data);
$processor->SetTarget($component);
$processor->SetProcessId(isset($subexercise['processorId'][$tempKey]) ? $subexercise['processorId'][$tempKey] : null);
// add attachement if given
if (isset($_FILES['exercises']) && isset($_FILES['exercises']['error']) && isset($_FILES['exercises']['error'][$key1]) && isset($_FILES['exercises']['error'][$key1]['subexercises']) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment']) && isset($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey])) {
if ($_FILES['exercises']['error'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey] != 4) {
$filePath = $_FILES['exercises']['tmp_name'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey];
$displayName = $_FILES['exercises']['name'][$key1]['subexercises'][$key2]['processAttachment'][$tempKey];
$attachments = array();
foreach ($filePath as $attachKey => $attachPath) {
$attachment = new Attachment();
$attachementFile = File::createFile(NULL, $displayName[$attachKey], NULL, $timestamp, NULL, NULL, NULL);
$attachementFile->setBody(Reference::createReference($attachPath));
$attachment->setFile($attachementFile);
$attachments[] = $attachment;
}
$processor->setAttachment($attachments);
}
}
$tempProcessors[$tempKey] = $processor;
}
if (isset($subexercise['processorParameterList']) && !empty($subexercise['processorParameterList']) && $subexercise['processorParameterList'] !== '') {
$processorParameter = $subexercise['processorParameterList'];
foreach ($processorParameter as $tempKey => $Data) {
$Data2 = array();
foreach ($Data as &$dat) {
if ($dat !== '') {
$Data2[] = $dat;