/** * 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. */ 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(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. * * @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(); }
/** * 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. */ 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(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. * * @param Component $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(LTutor::getPrefix(), dirname(__FILE__)); // runs the LTutor if ($com->used()) { return; } $conf = $com->loadConfig(); /** *Initialise the Slim-Framework */ $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); if (file_exists(dirname(__FILE__) . '/config.ini')) { $this->config = parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE); } /** *Set the Logiccontroller-URL */ $this->_conf = $conf; $this->query = array(); $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_postTransaction = array(CConfig::getLink($this->_conf->getLinks(), 'postTransaction')); $this->_getTransaction = array(CConfig::getLink($this->_conf->getLinks(), 'getTransaction')); $this->_postZip = array(CConfig::getLink($this->_conf->getLinks(), 'postZip')); $this->_postPdf = array(CConfig::getLink($this->_conf->getLinks(), 'postPdf')); $this->_postMarking = array(CConfig::getLink($this->_conf->getLinks(), 'postMarking')); $this->_getMarking = array(CConfig::getLink($this->_conf->getLinks(), 'getMarking')); $this->_getExercise = array(CConfig::getLink($this->_conf->getLinks(), 'getExercise')); $this->_getGroup = array(CConfig::getLink($this->_conf->getLinks(), 'getGroup')); $this->_getSubmission = array(CConfig::getLink($this->_conf->getLinks(), 'getSubmission')); $this->_postSubmission = array(CConfig::getLink($this->_conf->getLinks(), 'postSubmission')); // initialize lURL $this->lURL = $this->query->getAddress(); // POST AddPlatform $this->app->post('/platform', array($this, 'addPlatform')); // DELETE DeletePlatform $this->app->delete('/platform', array($this, 'deletePlatform')); // GET GetExistsPlatform $this->app->get('/link/exists/platform', array($this, 'getExistsPlatform')); // POST PostSubmissionConvert $this->app->post('/submission/convert(/timestamp/begin/:begin/end/:end)', array($this, 'postSubmissionConvert')); //Set auto allocation by exercise $this->app->post('/' . $this->getPrefix() . '/auto/exercise/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'autoAllocateByExercise')); //Set auto allocation by group $this->app->post('/' . $this->getPrefix() . '/auto/group/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'autoAllocateByGroup')); //Get zip $this->app->get('/' . $this->getPrefix() . '/user/:userid/exercisesheet/:sheetid(/status/:status)(/)', array($this, 'getZip')); //Post zip $this->app->post('/' . $this->getPrefix() . '/archive/user/:userid/exercisesheet/:sheetid(/)', array($this, 'postTutorArchive')); //Post zip $this->app->post('/' . $this->getPrefix() . '/archive/user/:userid/exercisesheet/:sheetid/withnames(/)', array($this, 'postTutorArchiveWithNames')); //uploadZip $this->app->post('/' . $this->getPrefix() . '/user/:userid/course/:courseid(/)', array($this, 'uploadZip')); //run Slim $this->app->run(); }
/** * the component constructor * * @param $conf component data */ public function __construct() { // runs the CConfig $com = new CConfig(DBControl::getPrefix(), dirname(__FILE__)); // runs the DBControl if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize component $this->_conf = $conf; // initialize slim $this->_app = new \Slim\Slim(); $this->_app->map('/:data+', array($this, 'getl'))->via('GET', 'POST', 'DELETE', 'PUT', 'INFO'); // run Slim $this->_app->run(); }
public function loadConfig($xmlFile) { $xmlFile = $this->m_path + $xmlFile; /* init cache object for config file */ $cCache = new CCache($this->m_cConf, $xmlFile); /* if I can use the cache, I use it or I cache it! */ if ($cCache->useCache == true) { $this->m_config = $cCache->getCache(); } /** * Cache config */ else { parent::loadConfig($xmlFile); $cCache->setCache($this->m_config); } }
/** * 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(DBAttachment::getPrefix(), dirname(__FILE__)); // runs the DBAttachment if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize component $this->_conf = $conf; $this->query = array(CConfig::getLink($conf->getLinks(), 'out')); $this->query2 = array(CConfig::getLink($conf->getLinks(), 'out2')); // initialize slim $this->_app = new \Slim\Slim(); $this->_app->response->setStatus(409); $this->_app->response->headers->set('Content-Type', 'application/json'); // POST AddPlatform $this->_app->post('/platform', array($this, 'addPlatform')); // DELETE DeletePlatform $this->_app->delete('/platform', array($this, 'deletePlatform')); // GET GetExistsPlatform $this->_app->get('/link/exists/platform', array($this, 'getExistsPlatform')); // PUT EditAttachment $this->_app->put('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment')); // DELETE DeleteAttachment $this->_app->delete('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment')); // DELETE DeleteExerciseAttachments $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'deleteExerciseAttachment')); // DELETE DeleteExerciseFileAttachment $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid/file/:fileid(/)', array($this, 'deleteExerciseFileAttachment')); // POST AddAttachment $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment')); // GET GetAttachment $this->_app->get('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment')); // GET GetAllAttachments $this->_app->get('/' . $this->getPrefix() . '(/attachment)(/)', array($this, 'getAllAttachments')); // GET GetExerciseAttachments $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments')); // GET GetSheetAttachments $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments')); // 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(LController::getPrefix(), dirname(__FILE__)); // runs the LController 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 = $conf->getLinks(); // POST/GET/PUT/DELETE chooseDestination $this->app->map('/:string+', array($this, 'chooseDestination'))->via('POST', 'GET', 'PUT', 'DELETE'); // 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(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(); }
/** * the component constructor */ public function __construct() { // runs the CConfig $com = new CConfig('link,definition'); // runs the CAbstract if ($com->used()) { $conf = $com->loadConfig(dirname(__FILE__) . '/' . (isset($com->pre) ? $com->pre : '')); $options = $conf->getOption(); $confFile = $com->confFile; if (isset($options)) { $data = explode(',', $options); foreach ($data as $dat) { $dat = explode('=', $dat); if ($dat[0] == 'confPath') { copy($confFile, dirname(__FILE__) . '/../../' . $dat[1]); } } } } return; }
/** * REST actions * * This function contains the REST actions with the assignments to * the functions. */ public function __construct() { // runs the CConfig $com = new CConfig(DBForm::getPrefix() . ',course,link', dirname(__FILE__)); // runs the DBForm if ($com->used()) { return; } $conf = $com->loadConfig(); // initialize component $this->_conf = $conf; $this->query = array(CConfig::getLink($conf->getLinks(), 'out')); // initialize slim $this->_app = new \Slim\Slim(); $this->_app->response->headers->set('Content-Type', 'application/json'); // POST AddCourse $this->_app->post('/course(/)', array($this, 'addCourse')); // POST DeleteCourse $this->_app->delete('/course/:courseid(/)', array($this, 'deleteCourse')); // PUT EditForm $this->_app->put('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'editForm')); // DELETE DeleteForm $this->_app->delete('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'deleteForm')); // POST AddForm $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addForm')); // GET GetForm $this->_app->get('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'getForm')); // GET GetCourseForms $this->_app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseForms')); // GET GetExistsCourseForms $this->_app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourseForms')); // GET GetSheetForms $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetForms')); // GET GetExerciseForms $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseForms')); // 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(); }
/** * 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(); }
/** * Führt das Modul entsprechend der Commands.json und Component.json Definitionen aus */ public function run() { // runs the CConfig $com = new CConfig($this->_prefix, $this->_path, $this->_noInfo, $this->_noHelp); // lädt die Konfiguration des Moduls if ($com->used()) { return; } $conf = $com->loadConfig(); $this->_conf = $conf; $this->_com = $com; $commands = $com->commands(array(), true, true); // multi Requests werden noch nicht unterstützt, das Model soll automatisch die Möglichkeit bieten, // mehrere Anfragen mit einmal zu beantworten ////$commands[] = array('name' => 'postMultiGetRequest','method' => 'POST', 'path' => '/multiGetRequest', 'inputType' => 'Link', 'outputType' => ''); // Erstellt für jeden angebotenen Befehl einen Router // Ein Router stellt einen erlaubten Aufruf dar (mit Methode und URI), sodass geprüft werden kann, // welcher für die Beantwortung zuständig ist $router = new \Slim\Router(); foreach ($commands as &$command) { if (!isset($command['name'])) { continue; } if (!isset($command['method'])) { $command['method'] = 'GET'; } if (!isset($command['callback'])) { $command['callback'] = $command['name']; } if (!isset($command['seqInput'])) { $command['seqInput'] = 'TRUE'; } if (!isset($command['singleOutput'])) { $command['singleOutput'] = 'FALSE'; } if (!isset($command['placeholder'])) { $command['placeholder'] = array(); } // Methoden können durch Komma getrennt aufgelistet sein $methods = explode(',', $command['method']); foreach ($methods as $method) { $route = new \Slim\Route($command['path'], array($this->_class, $command['callback']), false); $route->via(strtoupper($method)); $route->setName($command['name']); $router->map($route); // wenn es ein GET Befehl ist, wird automatisch HEAD unterstützt if (strtoupper($method) == 'GET') { // erzeugt einen HEAD Router $route = new \Slim\Route($command['path'], array($this->_class, $command['callback']), false); $route->via('HEAD'); $route->setName($command['name']); $router->map($route); } } } // hier wird die eingehende URI erzeugt // Bsp.: /user/1 $scriptName = $_SERVER['SCRIPT_NAME']; $requestUri = $_SERVER['REQUEST_URI']; $path = str_replace('?' . (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''), '', substr_replace($requestUri, '', 0, strlen(strpos($requestUri, $scriptName) !== false ? $scriptName : str_replace('\\', '', dirname($scriptName))))); // ermittelt den zuständigen Befehl $matches = $router->getMatchedRoutes(strtoupper($_SERVER['REQUEST_METHOD']), $path); if (count($matches) > 0) { // mindestens ein zutreffender Befehl wurde gefunden (nimm den Ersten) $matches = $matches[0]; // suche den zugehörigen $commands Eintrag $selectedCommand = null; foreach ($commands as $command) { if ($command['name'] === $matches->getName()) { $selectedCommand = $command; break; } } if ($selectedCommand == null) { http_response_code(500); return; } // lies die eingehenden PHP Daten $rawInput = \Slim\Environment::getInstance()->offsetGet('slim.input'); if (!$rawInput) { $rawInput = @file_get_contents('php://input'); } // wir wollen wissen, ob die Eingabedaten als Liste rein kommen $arr = true; // wenn zu diesem Befehl ein inputType angegeben wurde, wird eine Type::decodeType() aufgerufen if (isset($selectedCommand['inputType']) && trim($selectedCommand['inputType']) != '') { $inputType = $selectedCommand['inputType']; $rawInput = call_user_func_array('\\' . $inputType . '::decode' . $inputType, array($rawInput)); if (!is_array($rawInput)) { // es ist keine Liste, also mach eine daraus (damit man sie einheitlich behandeln kann) $rawInput = array($rawInput); $arr = false; } } if (strtoupper($selectedCommand['seqInput']) != 'TRUE') { $arr = false; } $params = $matches->getParams(); $placeholder = array(); // prüfe die Bedingungen für die Platzhalter foreach ($selectedCommand['placeholder'] as $holder) { if (!isset($holder['name'])) { continue; } if (!isset($holder['regex'])) { continue; } $placeholder[$holder['name']] = $holder['regex']; } /*foreach ($params as $key => $value){ if (isset($placeholder[$key])){ if (is_array($value)){ // wenn es ein Array ist, wurde ein :Element+ verwendet (Slim) // daher wird der Ausdruck auf jedes Element angewendet foreach($value as $val){ $pregRes = @preg_match($placeholder[$key], $val); if ($pregRes === false){ error_log(__FILE__.':'.__LINE__.' '.$placeholder[$key].' konnte nicht interpretiert werden'); $this->finishRequest(self::isError()); return; } else if ($pregRes === 0){ error_log(__FILE__.':'.__LINE__.' '.$val.' passt nicht zu '.$placeholder[$key]); $this->finishRequest(self::isPreconditionError()); return; } } } else { // einzelnes Element für Slim verwendet :Element $pregRes = @preg_match($placeholder[$key], $value); if ($pregRes === false){ error_log(__FILE__.':'.__LINE__.' '.$placeholder[$key].' konnte nicht interpretiert werden'); $this->finishRequest(self::isError()); return; } else if ($pregRes === 0){ error_log(__FILE__.':'.__LINE__.' '.$value.' passt nicht zu '.$placeholder[$key]); $this->finishRequest(self::isPreconditionError()); return; } } } }*/ // nun soll die zugehörige Funktion im Modul aufgerufen werden if (isset($selectedCommand['inputType']) && trim($selectedCommand['inputType']) != '' && isset($rawInput)) { // initialisiert die Ausgabe positiv $result = array("status" => 201, "content" => array()); if (strtoupper($selectedCommand['seqInput']) == 'TRUE') { try { // für jede Eingabe wird die Funktion ausgeführt foreach ($rawInput as $input) { // Aufruf der Modulfunktion $res = call_user_func_array($matches->getCallable(), array($selectedCommand['name'], "input" => $input, $params)); // wenn es ein Ausgabeobjekt gibt, wird versucht dort einen Status zu setzen if (is_callable(array($res['content'], 'setStatus'))) { $res['content']->setStatus($res['status']); } // setze Status und Ausgabe $result["content"][] = $res['content']; if (isset($res['status'])) { $result["status"] = $res['status']; } } } catch (Exception $e) { header_remove(); error_log($e->getMessage()); $this->finishRequest(self::isError()); return; } } else { try { // Aufruf der Modulfunktion $res = call_user_func_array($matches->getCallable(), array($selectedCommand['name'], "input" => $rawInput, $params)); // wenn es ein Ausgabeobjekt gibt, wird versucht dort einen Status zu setzen if (is_callable(array($res['content'], 'setStatus'))) { $res['content']->setStatus($res['status']); } // setze Status und Ausgabe $result["content"] = $res['content']; if (isset($res['status'])) { $result["status"] = $res['status']; } } catch (Exception $e) { header_remove(); error_log($e->getMessage()); $this->finishRequest(self::isError()); return; } } } else { // wenn keinen vorgegebenen Eingabetyp gibt, wird die Eingabe direkt an die Modulfunktion weitergegeben $result = call_user_func_array($matches->getCallable(), array($selectedCommand['name'], "input" => $rawInput, $params)); } if ($selectedCommand['method'] == 'HEAD') { // Bei einer HEAD Funktion (die eventuell im Modul als GET bearbeitet wird), // kann die Ausgabe verworfen werden $result['content'] = ''; } elseif (isset($selectedCommand['outputType']) && trim($selectedCommand['outputType']) != '' && trim($selectedCommand['outputType']) != 'binary') { // wenn ein Ausgabetyp angegeben ist, wird eine Typ::encodeTyp() ausgeführt $outputType = $selectedCommand['outputType']; if (isset($result['content'])) { if (!is_array($result['content'])) { $result['content'] = array($result['content']); } if ($command['singleOutput'] !== 'FALSE' && count($result['content']) >= 1) { $result['content'] = $result['content'][0]; } elseif (!$arr && count($result['content']) == 1) { $result['content'] = $result['content'][0]; } $result['content'] = call_user_func_array('\\' . $outputType . '::encode' . $outputType, array($result['content'])); } header('Content-Type: application/json'); } elseif (isset($selectedCommand['outputType']) && trim($selectedCommand['outputType']) == 'binary') { // wenn der Ausgabetyp "binär" ist, erfolgt keine Anpassung } else { // selbst wenn nichts zutrifft, wird json kodiert if (isset($result['content'])) { $result['content'] = json_encode($result['content']); } header('Content-Type: application/json'); } } else { // es wurde kein zutreffender Befehl gefunden, also gibt es eine leere Antwort $this->finishRequest(self::isError()); return; } // ab hier werden die Ergebnisse ausgegeben $this->finishRequest($result); }
public function __construct() { // runs the CConfig $com = new CConfig(LGetSite::getPrefix(), dirname(__FILE__)); // runs the LGetSite if ($com->used()) { return; } $conf = $com->loadConfig(); // Initialize Slim $this->app = new \Slim\Slim(); $this->app->response->headers->set('Content-Type', 'application/json'); // Set the logic controller URL $this->_conf = $conf; $this->query = CConfig::getLink($conf->getLinks(), "controller"); $this->_getUser = CConfig::getLink($conf->getLinks(), "getUser"); $this->_getExercise = CConfig::getLink($conf->getLinks(), "getExercise"); $this->_getExerciseType = CConfig::getLink($conf->getLinks(), "getExerciseType"); $this->_getExerciseFileType = CConfig::getLink($conf->getLinks(), "getExerciseFileType"); $this->_getApprovalCondition = CConfig::getLink($conf->getLinks(), "getApprovalCondition"); $this->_getMarking = CConfig::getLink($conf->getLinks(), "getMarking"); $this->_getSelectedSubmission = CConfig::getLink($conf->getLinks(), "getSelectedSubmission"); $this->_getGroup = CConfig::getLink($conf->getLinks(), "getGroup"); $this->_getCourseStatus = CConfig::getLink($conf->getLinks(), "getCourseStatus"); $this->_getSubmission = CConfig::getLink($conf->getLinks(), "getSubmission"); $this->_getCourse = CConfig::getLink($conf->getLinks(), "getCourse"); $this->_getInvitation = CConfig::getLink($conf->getLinks(), "getInvitation"); $this->lURL = $this->query->getAddress(); //GET TutorAssignmentSiteInfo $this->app->get('/tutorassign/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'tutorAssignmentSiteInfo')); //GET StudentSiteInfo $this->app->get('/student/user/:userid/course/:courseid(/)', array($this, 'studentSiteInfo')); //GET AccountSettings $this->app->get('/accountsettings/user/:userid(/course/:courseid)(/)', array($this, 'accountsettings')); //GET CreateSheet $this->app->get('/createsheet/user/:userid/course/:courseid(/)', array($this, 'createSheetInfo')); //GET Index $this->app->get('/index/user/:userid(/)', array($this, 'userWithAllCourses')); //GET CourseManagement $this->app->get('/coursemanagement/user/:userid/course/:courseid(/)', array($this, 'courseManagement')); //GET MainSettings $this->app->get('/mainsettings/user/:userid', array($this, 'mainSettings')); //GET Upload $this->app->get('/upload/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'upload')); //GET TutorUpload $this->app->get('/tutorupload/user/:userid/course/:courseid(/)', array($this, 'tutorUpload')); //GET MarkingTool $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'markingTool')); //GET MarkingTool $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/tutor/:tutorid', array($this, 'markingToolTutor')); //GET MarkingTool $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/status/:statusid', array($this, 'markingToolStatus')); //GET MarkingTool $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/tutor/:tutorid/status/:statusid', array($this, 'markingToolTutorStatus')); //GET UploadHistory $this->app->get('/uploadhistory/user/:userid/course/:courseid/exercisesheet/:sheetid/uploaduser/:uploaduserid(/)', array($this, 'uploadHistory')); //GET UploadHistoryOptions $this->app->get('/uploadhistoryoptions/user/:userid/course/:courseid(/)', array($this, 'uploadHistoryOptions')); //GET TutorSite $this->app->get('/tutor/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin')); //GET AdminSite $this->app->get('/admin/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin')); //GET DozentSite $this->app->get('/lecturer/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin')); //GET GroupSite $this->app->get('/group/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'groupSite')); //GET Condition $this->app->get('/condition/user/:userid/course/:courseid(/)', array($this, 'checkCondition')); //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(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(); }