/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LFormProcessor::getPrefix() . ',course,link', dirname(__FILE__)); // runs the LFormProcessor if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->_formDb = CConfig::getLinks($conf->getLinks(), "formDb"); $this->_pdf = CConfig::getLinks($conf->getLinks(), "pdf"); $this->_postProcess = CConfig::getLinks($conf->getLinks(), "postProcess"); $this->_deleteProcess = CConfig::getLinks($conf->getLinks(), "deleteProcess"); $this->_getProcess = CConfig::getLinks($conf->getLinks(), "getProcess"); // POST PostProcess $this->app->map('/' . $this->getPrefix() . '(/)', array($this, 'postProcess'))->via('POST'); // POST AddCourse $this->app->post('/course(/)', array($this, 'addCourse')); // POST DeleteCourse $this->app->delete('/course/:courseid(/)', array($this, 'deleteCourse')); // GET GetExistsCourse $this->app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourse')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LSubmission::getPrefix(), dirname(__FILE__)); // runs the LSubmission if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; ///$this->query = array(); $this->_file = CConfig::getLinks($conf->getLinks(), "file"); $this->_submission = CConfig::getLinks($conf->getLinks(), "submission"); $this->_selectedSubmission = CConfig::getLinks($conf->getLinks(), "selectedSubmission"); $this->_zip = CConfig::getLinks($conf->getLinks(), "zip"); // initialize lURL ///$this->lURL = $this->query->getAddress(); //AddSubmission $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addSubmission')); //EditSubmissionState $this->app->put('/' . $this->getPrefix() . '/submission/:submissionid(/)', array($this, 'editSubmissionState')); //deleteSubmission $this->app->delete('/' . $this->getPrefix() . '/submission/:submissionid(/)', array($this, 'deleteSubmission')); //LoadSubmissionAsZip $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/user/:userid(/)', array($this, 'loadSubmissionAsZip')); //ShowSubmissionsHistory $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/user/:userid/history(/)', array($this, 'showSubmissionsHistory')); //GetSubmissionFile $this->app->get('/' . $this->getPrefix() . '/submission/:submissionid(/)', array($this, 'getSubmissionFile')); $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LForm::getPrefix() . ',course,link', dirname(__FILE__)); // runs the LForm if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->_form = CConfig::getLinks($conf->getLinks(), "form"); $this->_choice = CConfig::getLinks($conf->getLinks(), "choice"); $this->_createCourse = CConfig::getLinks($conf->getLinks(), "postCourse"); // POST AddForm $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addForm')); // POST AddCourse $this->app->post('/course(/)', array($this, 'addCourse')); // DELETE DeleteCourse $this->app->delete('/course/:courseid(/)', array($this, 'deleteCourse')); // GET GetExistsCourse $this->app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourse')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LMarking::getPrefix(), dirname(__FILE__)); // runs the LMarking if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->_file = CConfig::getLinks($conf->getLinks(), "file"); $this->_marking = CConfig::getLinks($conf->getLinks(), "marking"); // POST AddMarking $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addMarking')); // GET GetMarkingURL $this->app->get('/' . $this->getPrefix() . '/marking/:markingid(/)', array($this, 'getMarkingURL')); // DELETE DeleteMarking $this->app->delete('/' . $this->getPrefix() . '/marking/:markingid(/)', array($this, 'deleteMarking')); // PUT EditMarking $this->app->put('/' . $this->getPrefix() . '/marking/:markingid(/)', array($this, 'editMarking')); // PUT EditMarkingStatus $this->app->put('/' . $this->getPrefix() . '/marking/:markingid/status(/)', array($this, 'editMarkingStatus')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LAttachment::getPrefix(), dirname(__FILE__)); // runs the LAttachment if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(); $this->app->response->setStatus(409); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_postFile = CConfig::getLinks($conf->getLinks(), "postFile"); $this->_postAttachment = CConfig::getLinks($conf->getLinks(), "postAttachment"); // initialize lURL $this->lURL = $this->query->getAddress(); //POST AddAttachment $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment')); //GET GetAttachment $this->app->get('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'getAttachment')); //DELETE DeleteAttachment $this->app->delete('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'deleteAttachment')); //PUT EditAttachment $this->app->put('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'editAttachment')); //run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LExtension::getPrefix() . ',course', dirname(__FILE__)); // runs the LExtension if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->_extension = CConfig::getLinks($conf->getLinks(), "extension"); //POST AddCourseExtension $this->app->post('/link/course/:courseid/extension/:name', array($this, 'addCourseExtension')); //DELETE DeleteCourseExtension $this->app->delete('/link/course/:courseid/extension/:name', array($this, 'deleteCourseExtension')); //DELETE DeleteCourse $this->app->delete('/course/:courseid/', array($this, 'deleteCourse')); //GET GetExtensionInstalled $this->app->get('/link/exists/course/:courseid/extension/:name', array($this, 'getExtensionInstalled')); //GET GetInstalledExtensions $this->app->get('/link/course/:courseid/extension', array($this, 'getInstalledExtensions')); //GET GetExtensions $this->app->get('/link/extension(/)', array($this, 'getExtensions')); //GET GetExtensionExists $this->app->get('/link/exists/extension/:name', array($this, 'getExtensionExists')); //GET GetExtension $this->app->get('/link/extension/:name', array($this, 'getExtension')); //run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LCourse::getPrefix(), dirname(__FILE__)); // runs the LCourse if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_deleteCourse = CConfig::getLinks($conf->getLinks(), "deleteCourse"); $this->_postCourse = CConfig::getLinks($conf->getLinks(), "postCourse"); // initialize lURL $this->lURL = $this->query->getAddress(); //POST AddCourse $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'AddCourse')); //PUT EditCourse $this->app->put('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'editCourse')); //DELETE DeleteCourse $this->app->delete('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'deleteCourse')); //POST AddCourseMember $this->app->post('/' . $this->getPrefix() . '/course/:courseid/user/:userid/status/:status(/)', array($this, 'addCourseMember')); //GET GetCourseMember $this->app->get('/' . $this->getPrefix() . '/course/:courseid/user(/)', array($this, 'getCourseMember')); //GET GetCourses $this->app->get('/' . $this->getPrefix() . '/user/:userid(/)', array($this, 'getCourses')); //run Slim $this->app->run(); }
/** * Ermittelt alle mit der CInstall am Ausgang $name verknüpften Komponenten * * @param string $name Der Name des Ausgangs, dessen Ziele gesucht ermittelt werden sollen * @return link[] Eine Liste der Komponenten an diesem Ausgang */ public static function getLinks($name) { if (self::$config === null) { self::$config = CConfig::loadStaticConfig('', '', dirname(__FILE__), '/../component/cinstall_cconfig.json'); } return CConfig::getLinks(self::$config->getLinks(), $name); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LExerciseSheet::getPrefix(), dirname(__FILE__)); // runs the LExerciseSheet if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_postFile = CConfig::getLinks($this->_conf->getLinks(), 'postFile'); $this->_deleteFile = CConfig::getLinks($this->_conf->getLinks(), 'deleteFile'); $this->_postExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'postExerciseSheet'); $this->_deleteExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'deleteExerciseSheet'); $this->_getExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'getExerciseSheet'); // initialize lURL $this->lURL = $this->query->getAddress(); // POST AddExerciseSheet $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addExerciseSheet')); // PUT EditExerciseSheet $this->app->put('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'editExerciseSheet')); // GET GetExerciseSheetURL $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/url(/)', array($this, 'getExerciseSheetURL')); // GET GetExerciseSheet $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'getExerciseSheet')); // GET GetExerciseSheet incl exercises $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/exercise(/)', array($this, 'getExerciseSheetExercise')); // GET GetExerciseSheet from course incl exercises $this->app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getExerciseSheetCourse')); // GET GetExerciseSheet from course incl exercises $this->app->get('/' . $this->getPrefix() . '/course/:courseid/exercise(/)', array($this, 'getExerciseSheetCourseExercise')); // DELETE DeleteExerciseSheet $this->app->delete('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'deleteExerciseSheet')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LExercise::getPrefix(), dirname(__FILE__)); // runs the LExercise if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_postAttachment = CConfig::getLinks($conf->getLinks(), "postAttachment"); // initialize lURL $this->lURL = $this->query->getAddress(); // POST AddExercise $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addExercise')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LProcessor::getPrefix() . ',submission,course,link', dirname(__FILE__)); // runs the LProcessor if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize slim $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component $this->_conf = $conf; $this->_submission = CConfig::getLinks($conf->getLinks(), "submission"); $this->_marking = CConfig::getLinks($conf->getLinks(), "marking"); $this->_processorDb = CConfig::getLinks($conf->getLinks(), "processorDb"); $this->_attachment = CConfig::getLinks($conf->getLinks(), "attachment"); $this->_workFiles = CConfig::getLinks($conf->getLinks(), "workFiles"); $this->_file = CConfig::getLinks($conf->getLinks(), "file"); $this->_createCourse = CConfig::getLinks($conf->getLinks(), "postCourse"); $this->_getExerciseExerciseFileType = CConfig::getLinks($conf->getLinks(), "getExerciseExerciseFileType"); // POST PostSubmission $this->app->map('/submission(/)', array($this, 'postSubmission'))->via('POST'); // POST AddProcess $this->app->map('/' . $this->getPrefix() . '(/)', array($this, 'addProcess'))->via('POST'); // POST AddCourse $this->app->post('/course(/)', array($this, 'addCourse')); // POST DeleteCourse $this->app->delete('/course/:courseid(/)', array($this, 'deleteCourse')); // GET GetExistsCourse $this->app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourse')); // run Slim $this->app->run(); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LOOP::getPrefix() . ',course,link', dirname(__FILE__)); // runs the LOOP if ($com->used()) { return; } $conf = $com->loadConfig(); // lädt die Daten der CConfig.json // initialize slim $this->app = new \Slim\Slim(array('debug' => true)); $this->app->response->headers->set('Content-Type', 'application/json'); // initialize component // hier werden die Verknüpfungen aus der CConfig.json ausgelesen (entsprechend ihrem Namen) $this->_conf = $conf; $this->_pdf = CConfig::getLinks($conf->getLinks(), "pdf"); // wird nicht genutzt, theoretisch koennten hier PDFs erzeugt werden // für POST /course zum eintragen als Verarbeitung (wird dann in CreateSheet aufgelistet) $this->_postProcess = CConfig::getLinks($conf->getLinks(), "postProcess"); $this->_deleteProcess = CConfig::getLinks($conf->getLinks(), "deleteProcess"); // für DELETE /course/xyz $this->_getProcess = CConfig::getLinks($conf->getLinks(), "getProcess"); // GET /link/exists/course/:courseid // POST PostProcess $this->app->map('/' . $this->getPrefix() . '(/)', array($this, 'postProcess'))->via('POST'); // POST AddCourse // fügt die Komponente der Veranstaltung hinzu (Daten kommen im Anfragekörper) $this->app->post('/course(/)', array($this, 'addCourse')); // DELETE DeleteCourse // entfernt die Komponente aus der Veranstaltung $this->app->delete('/course/:courseid(/)', array($this, 'deleteCourse')); // GET GetExistsCourse // zum Prüfen, ob diese Kompoenten korrekt installiert wurde (existiert Tabelleneintrag, konf-Dateien etc.) $this->app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourse')); // run Slim $this->app->run(); }
/** * Führt eine Anfrage über $linkName aus, wobei eine Verbindung mit der URI $order genutzt wird * * @param string $linkName Der Name des Ausgangs * @param mixed[] $params Die Ersetzungen für die Platzhalter des Befehls (Bsp.: array('uid'=>2,'cid'=>1) * @param string body Der Inhalt der Anfrage für POST und PUT * @param int $positiveStatus Der Status, welcher als erfolgreiche Antwort gesehen wird (Bsp.: 200) * @param callable $positiveMethod Im positiven Fall wird diese Methode aufgerufen * @param mixed[] $positiveParams Die Werte, welche an die positive Funktion übergeben werden * @param callable $negativeMethod Im negativen Fall wird diese Methode aufgerufen * @param mixed[] $negativeParams Die Werte, welche an die negative Funktion übergeben werden * @param string returnType Ein optionaler Rückgabetyp (es können Structures angegeben werden, sodass automatisch Typ::encodeType() ausgelöst wird) * @return mixed Das Ergebnis der aufgerufenen Resultatfunktion */ public function callByURI($linkName, $order, $params, $body, $positiveStatus, callable $positiveMethod, $positiveParams, callable $negativeMethod, $negativeParams, $returnType = null) { $links = CConfig::getLinks($this->_conf->getLinks(), $linkName); $link = null; $instructions = $this->_com->instruction('', true); // ermittle den zutreffenden Ausgang $selectedInstruction = null; foreach ($instructions as $instruction) { if ($instruction['name'] == $linkName) { $selectedInstruction = $instruction; break; } } if (isset($selectedInstruction['links'][0]['path']) && $selectedInstruction['links'][0]['path'] == $order) { $link = $links[0]; } else { foreach ($links as $li) { $testPath = $li->getPath(); $met = strpos($testPath, ' '); if ($met !== false) { $testPath = substr($testPath, $met + 1); foreach ($params as $key => $param) { $testPath = str_replace(':' . $key, $param, $testPath); } if ($testPath == $order) { $link = $li; break; } } } } if ($link == null) { return call_user_func_array($negativeMethod, $negativeParams); } $method = 'GET'; if ($link->getPath() !== null && $link->getPath() !== '') { $order = $link->getPath(); $met = strpos($order, ' '); if ($met !== false) { $method = substr($order, 0, $met); $order = substr($order, $met + 1); } else { return call_user_func_array($negativeMethod, $negativeParams); } } else { $order = $selectedInstruction['links'][0]['path']; if (isset($selectedInstruction['links'][0]['method'])) { $method = $selectedInstruction['links'][0]['method']; } } // ersetzt die Platzer im Ausgang mit den eingegeben Parametern foreach ($params as $key => $param) { $order = str_replace(':' . $key, $param, $order); } // führe nun den Aufruf aus $result = Request::routeRequest($method, $order, array(), $body, $link); if ($result['status'] == $positiveStatus) { // die Antwort war so, wie wir sie erwartet haben if ($returnType !== null) { // wenn ein erwarteter Rückgabetyp angegeben wurde, wird eine Typ::decodeType() ausgeführt $result['content'] = call_user_func_array('\\' . $returnType . '::decode' . $returnType, array($result['content'])); if (!is_array($result['content'])) { $result['content'] = array($result['content']); } } // rufe nun die positive Methode auf return call_user_func_array($positiveMethod, array_merge(array("input" => $result['content']), $positiveParams)); } // ansonsten rufen wir die negative Methode auf return call_user_func_array($negativeMethod, $negativeParams); }
/** * the getl function uses a list of links to find a * relevant component for the $data request * * @param $data a slim generated array of URI segments (String[]) */ public function getl($data) { Logger::Log('starts Controller routing', LogLevel::DEBUG); // if no URI is received, abort process if (count($data) == 0) { Logger::Log('Controller nothing to route', LogLevel::DEBUG); $this->_app->response->setStatus(409); $this->_app->stop(); return; } $URI = '/' . implode('/', $data); // get possible links $list = CConfig::getLinks($this->_conf->getLinks(), 'out'); foreach ($list as $links) { $componentURL = $links->getAddress(); $similar = Controller2::UrlAnd($componentURL, $URI); if ($similar != null) { $URI2 = substr($URI, Controller2::UrlAnd($componentURL, $URI)); $relevanz = explode(' ', $links->getRelevanz()); $found = false; foreach ($relevanz as $rel) { if ($rel == 'ALL') { $found = true; break; } $sub = strpos($rel, '_'); if ($sub !== false) { $method = substr($rel, 0, $sub); $path = substr($rel, $sub + 1); if (strtoupper($method) == strtoupper($this->_app->request->getMethod())) { $router = new \Slim\Router(); $route = new \Slim\Route($path, 'is_array'); $route->via(strtoupper($method)); $router->map($route); $routes = count($router->getMatchedRoutes(strtoupper($method), $URI2), true); if ($routes === 0) { continue; } $found = true; break; } } } if (!$found) { continue; } // create a custom request $ch = Request::custom($this->_app->request->getMethod(), $componentURL . substr($URI, $similar), array(), $this->_app->request->getBody()); // checks the answered status code if ($ch['status'] >= 200 && $ch['status'] <= 299) { // finished $this->_app->response->setStatus($ch['status']); $this->_app->response->setBody($ch['content']); if (isset($ch['headers']['Content-Type'])) { $this->_app->response->headers->set('Content-Type', $ch['headers']['Content-Type']); } if (isset($ch['headers']['Content-Disposition'])) { $this->_app->response->headers->set('Content-Disposition', $ch['headers']['Content-Disposition']); } Logger::Log('Controller2 search done', LogLevel::DEBUG); $this->_app->stop(); } } } // no positive response or no operative link $this->_app->response->setStatus(409); $this->_app->response->setBody(''); }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(LFile::$_baseDir, dirname(__FILE__)); // runs the LFile if ($com->used()) { return; } $conf = $com->loadConfig(); $this->_conf = $conf; $this->_fs = CConfig::getLinks($this->_conf->getLinks(), 'file'); $this->_db = CConfig::getLinks($this->_conf->getLinks(), 'fileDb'); $this->_app = new \Slim\Slim(array('debug' => true)); $this->_app->response->setStatus(404); $this->_app->response->headers->set('Content-Type', 'application/json'); // POST File $this->_app->post('/' . LFile::$_baseDir . '(/)', array($this, 'postFile')); /*// POST PathFile $this->_app->post( '/' . LFile::$_baseDir . '/:path(/)', array( $this, 'postPathFile' ) );*/ // DELETE File $this->_app->delete('/' . LFile::$_baseDir . '/:fileid', array($this, 'deleteFile')); // run Slim $this->_app->run(); }