예제 #1
0
 /**
  * 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();
 }
예제 #2
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBSetting::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBSetting
     if ($com->used()) {
         return;
     }
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:pre)/course', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('(/:pre)/course/:courseid', array($this, 'deleteCourse'));
     // PUT EditSetting
     $this->_app->put('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'editSetting'));
     // DELETE DeleteSetting
     $this->_app->delete('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'deleteSetting'));
     // POST AddSetting
     $this->_app->post('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'addSetting'));
     // GET GetExistsCourseSettings
     $this->_app->get('(/:pre)/link/exists/course/:courseid', array($this, 'getExistsCourseSettings'));
     // GET GetCourseSettings
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'getCourseSettings'));
     // GET GetSetting
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'getSetting'));
     // GET GetSettingByName
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid/name/:setname', array($this, 'getSettingByName'));
     // run Slim
     $this->_app->run();
 }
예제 #3
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBAttachment2::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBAttachment2
     if ($com->used()) {
         return;
     }
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:pre)/course(/)', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('(/:pre)/course/:courseid(/)', array($this, 'deleteCourse'));
     // PUT EditAttachment
     $this->_app->put('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
     // DELETE DeleteAttachment
     $this->_app->delete('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
     // POST AddAttachment
     $this->_app->post('(/:pre)/' . $this->getPrefix(), array($this, 'addAttachment'));
     // GET GetExistsCourseAttachments
     $this->_app->get('(/:pre)/link/exists/course/:courseid(/)', array($this, 'getExistsCourseAttachments'));
     // GET GetAttachment
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
     // GET GetExerciseAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
     // GET GetSheetAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
     // GET GetCourseAttachments
     $this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseAttachments'));
     // run Slim
     $this->_app->run();
 }
예제 #4
0
 /**
  * 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();
 }
예제 #5
0
 /**
  * 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();
 }
예제 #6
0
 /**
  * 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();
 }
예제 #7
0
 /**
  * the component constructor
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(CControl::getPrefix() . ',link,definition', dirname(__FILE__));
     // runs the DBSubmission
     if ($com->used()) {
         return;
     }
     // initialize slim
     $this->_app = new \Slim\Slim();
     $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'));
     // GET GetTableReferences
     $this->_app->get('/tableReferences', array($this, 'getTableReferences'));
     // PUT EditLink
     $this->_app->put('/link/:linkid(/)', array($this, 'editLink'));
     // DELETE DeleteLink
     $this->_app->delete('/link/:linkid(/)', array($this, 'deleteLink'));
     // POST SetLink
     $this->_app->post('/link(/)', array($this, 'setLink'));
     // GET GetLink
     $this->_app->get('/link/:linkid(/)', array($this, 'getLink'));
     // PUT EditComponent
     $this->_app->put('/component/:componentid(/)', array($this, 'editComponent'));
     // DELETE DeleteComponent
     $this->_app->delete('/component/:componentid(/)', array($this, 'deleteComponent'));
     // POST SetComponent
     $this->_app->post('/component(/)', array($this, 'setComponent'));
     // GET GetComponent
     $this->_app->get('/component/:componentid(/)', array($this, 'getComponent'));
     // GET GetComponentDefinitions
     $this->_app->get('/definition(/)', array($this, 'getComponentDefinitions'));
     // GET SendComponentDefinitions
     $this->_app->get('(/definition)/send(/)', array($this, 'sendComponentDefinitions'));
     // GET GetComponentDefinition
     $this->_app->get('/definition/:componentid(/)', array($this, 'getComponentDefinition'));
     // run Slim
     $this->_app->run();
 }
예제 #8
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig('transaction,course,link', dirname(__FILE__));
     // runs the DBTransaction
     if ($com->used()) {
         return;
     }
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:name)/course', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('(/:name)/course/:courseid', array($this, 'deleteCourse'));
     // GET GetExistsCourseTransactions
     $this->_app->get('(/:name)/link/exists/course/:courseid', array($this, 'getExistsCourseTransactions'));
     // DELETE DeleteTransaction
     $this->_app->delete('(/:name)/transaction/authentication/:auid/transaction/:tid', array($this, 'deleteTransaction'));
     // DELETE DeleteTransactionShort
     $this->_app->delete('(/:name)/transaction/transaction/:tid', array($this, 'deleteTransactionShort'));
     // POST AddTransaction
     $this->_app->post('(/:name)/transaction/course/:courseid', array($this, 'addTransaction'));
     // POST AddSheetTransaction
     $this->_app->post('(/:name)/transaction/exercisesheet/:esid', array($this, 'addSheetTransaction'));
     // POST AddExerciseTransaction
     $this->_app->post('(/:name)/transaction/exercise/:eid', array($this, 'addExerciseTransaction'));
     // GET GetTransaction
     $this->_app->get('(/:name)/transaction/authentication/:auid/transaction/:tid', array($this, 'getTransaction'));
     // GET GetTransactionShort
     $this->_app->get('(/:name)/transaction/transaction/:tid', array($this, 'getTransactionShort'));
     // GET GetAmountOfExpiredTransactions
     $this->_app->get('(/:name)/clean/clean/course/:courseid', array($this, 'getAmountOfExpiredTransactions'));
     // DELETE CleanTransactions
     $this->_app->delete('(/:name)/clean/clean/course/:courseid', array($this, 'cleanTransactions'));
     // run Slim
     $this->_app->run();
 }
예제 #9
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBChoice::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBChoice
     if ($com->used()) {
         return;
     }
     // initialize component
     $this->_conf = $com;
     // initialize slim
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/course', array($this, 'addCourse'));
     // DELETE DeleteCourse
     $this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/course(/course)/:courseid', array($this, 'deleteCourse'));
     // PUT EditChoice
     $this->_app->put('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'editChoice'));
     // DELETE DeleteChoice
     $this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'deleteChoice'));
     // POST AddChoice
     $this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/)', array($this, 'addChoice'));
     // GET GetChoice
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'getChoice'));
     // GET GetCourseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseChoices'));
     // GET GetExistsCourseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/link/exists/course/:courseid(/)', array($this, 'getExistsCourseChoices'));
     // GET GetSheetChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetChoices'));
     // GET GetExerciseChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseChoices'));
     // GET GetFormChoices
     $this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/form/:formid(/)', array($this, 'getFormChoices'));
     // run Slim
     $this->_app->run();
 }
예제 #10
0
 /**
  * Test middleware returns diagnostic screen for error response
  */
 public function testReturnsDiagnosticsForErrorResponse()
 {
     Slim_Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new Slim(array('log.enabled' => false));
     $app->get('/foo', function () {
         throw new Exception('Test Message', 100);
     });
     $mw = new Slim_Middleware_PrettyExceptions();
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $this->assertEquals(1, preg_match('@Slim Application Error@', $app->response()->body()));
     $this->assertEquals(500, $app->response()->status());
 }
 /**
  * Test middleware overrides response content type to html
  */
 public function testResponseContentTypeIsOverriddenToHtml()
 {
     Slim_Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new Slim(array('log.enabled' => false));
     $app->get('/foo', function () use($app) {
         $app->contentType('application/json;charset=utf-8');
         //<-- set content type to something else
         throw new Exception('Test Message', 100);
     });
     $mw = new Slim_Middleware_PrettyExceptions();
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $response = $app->response();
     $this->assertEquals('text/html', $response['Content-Type']);
 }
예제 #12
0
 /**
  * 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();
 }
예제 #13
0
 /**
  * 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();
 }
예제 #14
0
파일: LOOP.php 프로젝트: sawh/ostepu-system
 /**
  * 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();
 }
예제 #15
0
<?php

/*
Esta es la parte de la aplicacion que se encargará de hacer la administracion
de las maquinas en la base de datos, 
*/
include "../inc/database.php";
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/equipments', 'index');
$app->get('/piezas', 'piezas_maquina');
function index()
{
    // updateMachinesMxOptix();
    $query = file_get_contents('sql/minutos.maquina.sql');
    $DB = new Prod();
    $DB->setQuery($query);
    $DB->exec();
    if ($DB->json() == "[]") {
        throw new Exception("No arrojo datos la base de datos", 1);
    } else {
        echo $DB->json();
    }
}
function piezas_maquina()
{
    // updateMachinesMxOptix();
    $lastCalculatedFileName = 'lk3456kjgadfmlcvjdfbladfq984874.txt';
    $query = file_get_contents('sql/piezas.turno.sql');
    $today = strtotime("now");
    $horaMilitar = date('Hi', $today);
예제 #16
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/beers', 'getBeers');
$app->get('/beers/:id', 'getBeer');
$app->get('/beers/search/:query', 'findByName');
$app->post('/beers', 'addBeer');
$app->put('/beers/:id', 'updateBeer');
$app->delete('/beers/:id', 'deleteBeer');
$app->run();
function getBeers()
{
    $sql = "select * FROM wine ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $beers = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($beers) . '}';
        echo json_encode($beers);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getBeer($id)
{
    $sql = "SELECT * FROM wine WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #17
0
<?php

session_start();
require 'Business/PatientData.php';
require 'Business/DoctorData.php';
require 'Business/StaffData.php';
require 'Business/MasterData.php';
require 'Slim/Slim.php';
$app = new Slim();
error_reporting(E_ALL);
ini_set("log_errors", true);
ini_set("error_log", "/Applications/MAMP/htdocs/HealthCareSystem/RestAPI/errorlog.log");
$app->get('/authenticate/:username/:password', 'authenticateUser');
$app->get('/', 'initialMessage');
$app->post('/registerUser', 'registerUser');
$app->put('/updateprofile/:id', 'updateProfile');
$app->get('/appointmentsList/:hosiptal/:doctor/:appdate', 'appointmentsList');
$app->post('/createAppointment', 'createAppointment');
$app->get('/hosiptalDoctorData', 'hosiptalDoctorData');
$app->get('/professionBasedData/:profession/:name', 'professionBasedData');
$app->get('/doctorMasterData/:doctorId', 'doctorMasterData');
$app->get('/userMasterData/:userId', 'userMasterData');
$app->post('/createUser', 'createUser');
$app->get('/patientList/:patientName', 'patientList');
$app->get('/appointmentPatientList/:patientName/:hosiptal/:appdate', 'appointmentPatientList');
$app->put('/updateAppointment/:appointmentId', 'updateAppointment');
$app->run();
function initialMessage()
{
    try {
        //echo "<h1>Hello Slim World</h1>";
예제 #18
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->config("mode", "production");
$app->get('/say/hello/:name', function ($name) {
    echo "Hello, {$name}!";
});
$app->run();
예제 #19
0
        }
    }
    // sort our posts (inversely) by created date (the key value)
    krsort($posts);
    // return our posts
    return $posts;
};
// ----------------------------------------------------------
// ------------------------ ROUTES --------------------------
// home page
$blog->get('/', function () use($blog, $getMarkdownPosts) {
    // get our posts
    $posts = $getMarkdownPosts($blog->config('posts.path'));
    // limit our posts to pagination
    $posts_limit = array_slice($posts, 0, $blog->config('pagination'));
    // get the total number of posts
    $posts_count = count($posts);
    // calculate the number of page
    $pages_number = ceil($posts_count / $blog->config('pagination'));
    // render the main page
    $blog->render('index.html', array('posts' => $posts_limit, 'page_current' => 1, 'page_count' => $pages_number));
});
// about page
$blog->get('/about', function () use($blog) {
    // render the about page
    $blog->render('about.html');
});
// projects page
$blog->get('/projects', function () use($blog) {
    // render the blog page
    $blog->render('projects.html');
});
예제 #20
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/wines', 'getWines');
$app->get('/wines/:id', 'getWine');
$app->get('/wines/search/:query', 'findByName');
$app->post('/wines', 'addWine');
$app->put('/wines/:id', 'updateWine');
$app->delete('/wines/:id', 'deleteWine');
$app->run();
function getWines()
{
    $sql = "select * FROM wine ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($wines) . '}';
        echo json_encode($wines);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getWine($id)
{
    $sql = "SELECT * FROM wine WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #21
0
$app = new Slim();
$facebook = new Facebook(array('appId' => $_SERVER['HTTP_FB_APPID'], 'secret' => $_SERVER['HTTP_FB_SECRET']));
/**
 * 過去20件のイベント情報
 */
$app->get('/fb/event/last_20.json', function () use($facebook) {
    $uid = '131130253626713';
    $yesterday = time() - 60 * 60 * 12;
    $fql = <<<____FQL
\t\tSELECT description, eid, name, pic_small, start_time
\t\tFROM event
\t\tWHERE
\t\t\teid in (
\t\t\t\tSELECT eid 
\t\t\t\tFROM event_member 
\t\t\t\tWHERE uid = {$uid} AND 0 < start_time AND start_time < {$yesterday})
\t\t\tAND privacy = 'OPEN'
\t\tORDER BY start_time DESC
\t\tLIMIT 20
____FQL;
    $result = $facebook->api(array('method' => 'fql.query', 'query' => $fql));
    $data = array();
    foreach ($result as $row) {
        $data[] = array('description' => mb_strimwidth($row['description'], 0, 400, '...', 'UTF-8'), 'eid' => $row['eid'], 'name' => preg_replace('/^下北沢オープンソースCafe - /', '', $row['name']), 'pic_small' => $row['pic_small'], 'date' => date('M j', strtotime($row['start_time'])), 'day' => date('D', strtotime($row['start_time'])));
    }
    echo json_encode($data);
});
/**
 * 週始めから4週間分のイベント情報
 */
$app->get('/fb/event/calendar.json', function () use($facebook) {
    $uid = '131130253626713';
예제 #22
0
파일: SlimTest.php 프로젝트: ntdt/Slim
 /**
  * Test Slim returns 200 OK for successful route
  *
  * Pre-conditions:
  * You have initialized a Slim app with an accessible route that
  * does not throw any Exceptions and does not set a custom status.
  *
  * Post-conditions:
  * The response status is 200 and response body is as expected.
  */
 public function testSlimOkResponse() {
     Slim::init();
     Slim::get('/', function () { echo "Ok"; });
     Slim::run();
     $this->assertEquals(Slim::response()->status(), 200);
     $this->assertEquals(Slim::response()->body(), 'Ok');
 }
예제 #23
0
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
        header("Access-Control-Allow-Methods: GET, PUT, POST, OPTIONS");
    }
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
        header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    }
    exit(0);
}
require_once 'Slim/Slim.php';
require_once 'models/User.php';
$app = new Slim();
$user = new User();
$app->get('/users', function () use($user) {
    $user->getAll();
});
$app->get('/users/:id', function ($id) use($user) {
    $user->getById($id);
});
$app->get('/users/:id/friends', function ($id) use($user) {
    $user->getFriends($id);
});
$app->get('/users/:id/score', function ($id) use($user) {
    $user->getScore($id);
});
$app->get('/users/:id/rewards', function ($id) use($user) {
    $user->getRewards($id);
});
$app->get('/users/search/:name', function ($name) use($user) {
    $user->getByName($name);
예제 #24
0
<?php

require dirname(__FILE__) . '/../Slim/Slim.php';
$app = new Slim();
$app->get("/", "getStores");
$app->get("/:id", "getStore");
$app->get("/search/:query", "findByName");
$app->post("/", "addStore");
$app->put("/:id", "updateStore");
$app->delete("/:id", "deleteStore");
$app->run();
function getStores()
{
    $sql = "select * FROM store ORDER BY name";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $stores = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        // echo '{"wine": ' . json_encode($wines) . '}';
        echo json_encode($stores);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getStore($id)
{
    $sql = "SELECT * FROM store WHERE id=:id";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);
예제 #25
0
 /**
  * Test $_SESSION is populated as empty array if no HTTP cookie
  */
 public function testSessionIsPopulatedAsEmptyIfNoCookie()
 {
     Slim_Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new Slim();
     $app->get('/foo', function () {
         echo "Success";
     });
     $mw = new Slim_Middleware_SessionCookie(array('expires' => '10 years'));
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $this->assertEquals(array(), $_SESSION);
 }
예제 #26
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/new-events', 'listNewEvents');
$app->put('/ack-event/:id', 'acknowledgeEvent');
$app->run();
function listNewEvents()
{
    $sql = "SELECT event_id, user_id, wf_id, event_msg FROM events WHERE event_status=0 ORDER BY event_id";
    try {
        $dbT = getConnt();
        $stmt = $dbT->query($sql);
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $dbT = null;
        echo json_encode($wines);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function acknowledgeEvent($id)
{
    //$eid = $request->params('eid');
    $sql = "UPDATE `events` SET event_status=2 WHERE event_id=:id";
    try {
        //$dbT = getConnection();
        $dbT = getConnt();
        $stmt = $dbT->prepare($sql);
        //$stmt->bindParam("id", $eid)
        $stmt->bindParam("id", $id);
        $stmt->execute();
예제 #27
0
<?php

require 'Slim/Slim.php';
$app = new Slim();
$app->get('/users', 'getUsers');
$app->post('/users', 'addUser');
$app->get('/users/:id', 'getUser');
$app->get('/users/search/:query', 'findByName');
$app->put('/users/:id', 'updateUser');
$app->delete('/users/:id', 'deleteUser');
$app->run();
function getConnection()
{
    $dbhost = "127.0.0.1";
    $dbuser = "******";
    $dbpass = "******";
    $dbname = "angular-mysql";
    $dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $dbh;
}
function getUsers()
{
    $sql = "select * FROM users ORDER BY id";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $users = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($users);
    } catch (PDOException $e) {
예제 #28
0
파일: index.php 프로젝트: artemklv/shelfari
<?php

require "includes/index.php";
require_once "Slim/Slim.php";
$data = new Slim();
$data->get('/books/search', function () use($data) {
    $query = $data->request()->params('name');
    findByName($query);
});
$data->get('/books', 'getBooks');
$data->get('/books/:id', 'getBook');
//$data->get('/books/search:query', 'findByName');
$data->post('/books', 'addBook');
$data->put('/books/:id', 'updateBook');
$data->delete('/books/:id', 'deleteBook');
$data->run();
function getBooks()
{
    $sql = "select * FROM books ORDER BY id DESC";
    try {
        $db = getConnection();
        $stmt = $db->query($sql);
        $books = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($books);
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
function getBook($id)
{
예제 #29
0
<?php

set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/library'), get_include_path())));
require_once 'Slim/Slim.php';
require_once 'controller/ProdutosController.php';
$app = new Slim();
$pcontroller = new ProdutosController();
$app->get('/produtos', function () use($pcontroller) {
    echo json_encode($pcontroller->listarProdutos());
});
$app->post('/produtos', function () use($pcontroller, $app) {
    $produto = json_decode(file_get_contents("php://input"));
    echo json_encode($pcontroller->salvarProduto($produto));
});
$app->put('/produtos', function () use($pcontroller, $app) {
    $produto = $app->request()->put();
    unset($produto['$$hashKey']);
    echo json_encode($pcontroller->atualizarProduto($produto));
});
$app->delete('/produtos/:id', function ($id) use($pcontroller) {
    echo $pcontroller->removerProduto($id);
});
$app->run();
예제 #30
-1
 public function run()
 {
     $that = $this;
     $app = new \Slim(array('view' => 'rg\\broker\\web\\View', 'templates.path' => './src/rg/broker/web/templates'));
     $this->app = $app;
     $app->get('/', function () use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $mdParser = new \dflydev\markdown\MarkdownParser();
         $content = $mdParser->transformMarkdown(file_get_contents(ROOT . '/README.md'));
         $app->render('home.php', array('repositories' => $that->getRepositories(), 'content' => $content));
     });
     $app->get('/repositories/:repositoryName/', function ($repositoryName) use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $app->render('repository.php', array('repositories' => $that->getRepositories(), 'currentRepository' => $that->getRepository($repositoryName)));
     });
     $app->get('/repositories/:repositoryName/package/:packageName', function ($repositoryName, $packageName) use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $packageName = urldecode($packageName);
         $app->render('package.php', array('repositories' => $that->getRepositories(), 'currentRepository' => $that->getRepository($repositoryName), 'package' => $that->getPackage($repositoryName, $packageName)));
     });
     $app->run();
 }