Ejemplo n.º 1
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->method('GET|POST');
     $c->match('/editcontent/{contenttypeslug}/{id}', 'edit')->bind('editcontent')->assert('id', '\\d*')->value('id', '');
     $c->get('/overview/{contenttypeslug}', 'overview')->bind('overview');
     $c->get('/relatedto/{contenttypeslug}/{id}', 'related')->bind('relatedto')->assert('id', '\\d*');
 }
Ejemplo n.º 2
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/login', 'getLogin')->bind('login');
     $c->post('/login', 'postLogin')->bind('postLogin');
     $c->match('/logout', 'logout')->bind('logout');
     $c->get('/resetpassword', 'resetPassword')->bind('resetpassword');
 }
Ejemplo n.º 3
0
Archivo: Log.php Proyecto: d-m-/bolt
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/changelog', 'changeOverview')->bind('changelog');
     $c->get('/changelog/{contenttype}/{contentid}/{id}', 'changeRecord')->assert('id', '\\d*')->bind('changelogrecordsingle');
     $c->get('/changelog/{contenttype}/{contentid}', 'changeRecordListing')->value('contentid', '0')->value('contenttype', '')->bind('changelogrecordall');
     $c->get('/systemlog', 'systemOverview')->bind('systemlog');
 }
Ejemplo n.º 4
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/users/new', array($this, 'newAction'))->bind('user_new');
     $controllers->post('/users/new', array($this, 'handleNewAction'))->bind('user_new_handle');
     $controllers->get('/users/choose', array($this, 'chooseAction'))->bind('user_choose');
     $controllers->get('/users/{name}', array($this, 'showAction'))->bind('user_show');
 }
Ejemplo n.º 5
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/tokens', array($this, 'indexAction'))->bind('user_tokens');
     $controllers->get('/tokens/new', array($this, 'newAction'))->bind('user_tokens_new');
     $controllers->post('/tokens/new', array($this, 'newAction'))->bind('user_tokens_new_process');
     $controllers->post('/tokens/{token}/delete', array($this, 'deleteAction'))->bind('user_tokens_delete');
 }
Ejemplo n.º 6
0
 public function connect(Application $app)
 {
     $this->app = $app;
     // api v1
     $api = new ControllerCollection(new Route());
     $api->get('/{model}', __CLASS__ . '::listAction')->assert('model', '^([a-z]+)$');
     $api->get('/{model}/{id}', __CLASS__ . '::itemAction')->assert('model', '^([a-z]+)$')->assert('id', '^([a-z0-9]+)$');
     $api->delete('/{model}/{id}', __CLASS__ . '::deleteAction')->assert('model', '^([a-z]+)$')->assert('id', '^([a-z0-9]+)$');
     $api->put('/{model}/{id}', __CLASS__ . '::updateAction')->assert('model', '^([a-z]+)$')->assert('id', '^([a-z0-9]+)$');
     $api->post('/{model}', __CLASS__ . '::createAction')->assert('model', '^([a-z]+)$');
     //        $model = $this->checkModel('message');
     //
     //        foreach (range(900, 1000) as $id)
     //        {
     //            $message = new $model;
     //
     //            $message->text = $id;
     //            $message->date = time();
     //
     //            $this->dm->persist($message);
     //        }
     //
     //        $this->dm->flush();
     return $api;
 }
Ejemplo n.º 7
0
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $controllers->get('auth', function () use($app) {
         if ($app['session']->has($app['config']['prefix'] . 'authed-user')) {
             return $app->redirect('/');
         }
         return $app['twig']->render('PT/pages/authenticate.html', array('auth_path' => $app['uri']->generate('authenticate')));
     })->bind('authenticate');
     $controllers->post('auth', function () use($app) {
         if ($app['request']->get('username') === $app['config']['authenticate']['username'] && $app['request']->get('password') === $app['config']['authenticate']['password']) {
             $userHash = $userHash = sha1($app['config']['authenticate']['username'] . $app['config']['authenticate']['password']);
             $currentUser = $app['session']->set($app['config']['prefix'] . 'authed-user', $userHash);
             return $app->redirect('/');
         } else {
             $app['session']->setFlash('error', 'error');
             $app['session']->remove($app['config']['prefix'] . 'authed-user');
             return $app->redirect($app['uri']->generate('authenticate'));
         }
     })->bind('do_authenticate');
     $controllers->get('deauth', function ($result) use($app) {
         $app['session']->remove($app['config']['prefix'] . 'authed-user');
         return $app->redirect($app['uri']->generate('authenticate'));
     })->value('result', null)->bind('de_authenticate');
     return $controllers;
 }
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $supervisor = new API();
     $servers = (include __DIR__ . '/../../config.php');
     foreach (array_keys($servers) as $server_id) {
         $servers[$server_id]['id'] = $server_id;
     }
     $controllers->get('/list.{_format}', function ($_format) use($supervisor, $app, $servers) {
         if ($_format == 'json') {
             return $app->json($servers);
         } else {
             // use a closure to avoid leaking any vars into the template that we don't explicitly want
             return call_user_func(function () use($app) {
                 $url_root = $app['url_generator']->generate('home');
                 ob_start();
                 ob_implicit_flush(false);
                 include __DIR__ . '/../../views/supervisorui.html.php';
                 return ob_get_clean();
             });
         }
     })->bind('server_list')->value('_format', 'html');
     $controllers->get('/details/{server_id}', function ($server_id) use($supervisor, $app, $servers) {
         $server_ip = $servers[$server_id]['ip'];
         $details = array_merge(array('version' => $supervisor->getSupervisorVersion('127.0.0.1'), 'pid' => $supervisor->getPID('127.0.0.1')), $supervisor->getState('127.0.0.1'), $servers[$server_id]);
         return $app->json($details);
     });
     return $controllers;
 }
Ejemplo n.º 9
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/password/generate', [$this, 'generatePassword']);
     $controllers->post('/password/generate', [$this, 'generatePassword']);
     $controllers->get('/password/complication', [$this, 'complicationPassword']);
     $controllers->get('/secret', [$this, 'secret']);
 }
Ejemplo n.º 10
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/programmers/new', array($this, 'newAction'))->bind('programmer_new');
     $controllers->post('/programmers/new', array($this, 'handleNewAction'))->bind('programmer_new_handle');
     $controllers->get('/programmers/choose', array($this, 'chooseAction'))->bind('programmer_choose');
     $controllers->get('/programmers/{nickname}', array($this, 'showAction'))->bind('programmer_show');
     $controllers->post('/programmers/{nickname}/power/up', array($this, 'powerUpAction'))->bind('programmer_powerup');
 }
Ejemplo n.º 11
0
 /**
  * {@inheritDoc}
  */
 public function mount(ControllerCollection $controllers)
 {
     $controllers->get('/', [$this, 'indexAction'])->bind('config_index');
     $controllers->get('/edit', [$this, 'editAction'])->bind('config_edit');
     $controllers->post('/edit', [$this, 'updateAction'])->bind('config_update');
     $controllers->get('/repository/{type}/form-fragment/{index}', [$this, 'retrieveRepositoryFormFragmentAction'])->bind('retrieve_repository_form_fragment');
     $controllers->post('/config/build', [$this, 'buildAction'])->bind('config_build');
 }
Ejemplo n.º 12
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/nodes', [$this, 'all']);
     $controllers->get('/node/{id}', [$this, 'show']);
     $controllers->post('/node', [$this, 'create']);
     $controllers->put('/node/{id}', [$this, 'update']);
     $controllers->delete('/node/{id}', [$this, 'delete']);
 }
 /**
  * @param ControllerCollection $controllers
  * @return ControllerCollection
  */
 private function setControllerPaths(ControllerCollection $controllers)
 {
     $controllers->get('/{id}', self::READ_REST_CONTROLLER . ':get');
     $controllers->patch('/{id}', self::EDIT_REST_CONTROLLER . ':patch');
     $controllers->get('/', self::READ_REST_CONTROLLER . ':search');
     $controllers->post('/', self::EDIT_REST_CONTROLLER . ':create');
     return $controllers;
 }
Ejemplo n.º 14
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/register', array($this, 'registerAction'))->bind('user_register');
     $controllers->post('/register', array($this, 'registerHandleAction'))->bind('user_register_handle');
     $controllers->get('/login', array($this, 'loginAction'))->bind('user_login');
     $controllers->post('/login_check', array($this, 'longCheckAction'))->bind('user_login_check');
     $controllers->get('/logout', array($this, 'logoutAction'))->bind('user_logout');
 }
Ejemplo n.º 15
0
 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->post('/api/users', array($this, 'newAction'));
     $controllers->get('/api/users/{name}', array($this, 'showAction'))->bind('api_users_show');
     $controllers->get('/api/users', array($this, 'listAction'));
     $controllers->put('/api/users/{name}', array($this, 'updateAction'));
     $controllers->delete('/api/users/{name}', array($this, 'deleteAction'));
     $controllers->match('api/users/{name}', array($this, 'updateAction'))->method('PATCH');
 }
Ejemplo n.º 16
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->method('GET|POST');
     $c->get('/list/{contenttypeslug}', 'overview')->bind('overview');
     $c->match('/add-edit/{contenttypeslug}/{id}', 'edit')->bind('editcontent')->value('id', '');
     $c->get('/delete/{contenttypeslug}/{id}', 'delete')->bind('deletecontent');
     $c->post('/content-{action}/{contenttypeslug}/{id}', 'modify')->bind('contentaction');
     $c->get('/relatedto/{contenttypeslug}/{id}', 'related')->bind('relatedto');
 }
Ejemplo n.º 17
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/users', 'admin')->bind('users');
     $c->match('/users/edit/{id}', 'edit')->assert('id', '\\d*')->bind('useredit');
     $c->match('/userfirst', 'first')->bind('userfirst');
     $c->post('/user/{action}/{id}', 'modify')->bind('useraction');
     $c->match('/profile', 'profile')->bind('profile');
     $c->get('/roles', 'viewRoles')->bind('roles');
 }
Ejemplo n.º 18
0
 /**
  *
  *
  * @param ControllerCollection $factory
  * @return null
  */
 public function createRoutes(ControllerCollection $factory)
 {
     $factory->get('/files', [$this, 'get']);
     $factory->get('/files/{hash}', [$this, 'getOne']);
     $factory->post('/files/{hash}', [$this, 'userAction']);
     $factory->delete('/files/{hash}', [$this, 'remove'])->onlyAdmin();
     $factory->put('/files/{hash}', [$this, 'update'])->onlyAdmin();
     $factory->get('/artists', [$this, 'getArtists']);
 }
Ejemplo n.º 19
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/about', 'about')->bind('about');
     $c->get('/checks', 'checks')->bind('checks');
     $c->get('/clearcache', 'clearCache')->bind('clearcache');
     $c->get('/', 'dashboard')->bind('dashboard');
     $c->get('/omnisearch', 'omnisearch')->bind('omnisearch-results');
     $c->match('/prefill', 'prefill')->bind('prefill');
     $c->match('/tr/{domain}/{tr_locale}', 'translation')->bind('translation')->assert('domain', 'messages|contenttypes|infos')->value('domain', 'messages')->value('tr_locale', $this->app['locale']);
 }
Ejemplo n.º 20
0
 public function connect(Application $app)
 {
     $index = new ControllerCollection(new Route());
     $index->get('/', function () use($app) {
         $label = $app['models']->load('Pages', 'index');
         return $label;
     });
     $index->get('/{name}', function ($name) use($app) {
         $name = $app['models']->load('Pages', 'hello', $name);
         return "Hello {$name}";
     });
     return $index;
 }
Ejemplo n.º 21
0
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/', 'async')->bind('async');
     $c->get('/changelog/{contenttype}/{contentid}', 'changeLogRecord')->value('contenttype', '')->value('contentid', '0')->bind('changelogrecord');
     $c->get('/dashboardnews', 'dashboardNews')->bind('dashboardnews');
     $c->get('/lastmodified/{contenttypeslug}/{contentid}', 'lastModified')->value('contentid', '')->bind('lastmodified');
     $c->get('/latestactivity', 'latestActivity')->bind('latestactivity');
     $c->get('/makeuri', 'makeUri')->bind('makeuri');
     $c->get('/omnisearch', 'omnisearch')->bind('omnisearch');
     $c->get('/readme/{filename}', 'readme')->assert('filename', '.+')->bind('readme');
     $c->get('/populartags/{taxonomytype}', 'popularTags')->bind('populartags');
     $c->get('/tags/{taxonomytype}', 'tags')->bind('tags');
 }
Ejemplo n.º 22
0
 protected function addRoutes(ControllerCollection $ctr)
 {
     $ctr->get('/browse/{namespace}/{path}', 'browse')->assert('path', '.*')->value('namespace', 'files')->value('path', '')->bind('asyncbrowse');
     $ctr->get('/file/autocomplete', 'filesAutoComplete')->bind('file/autocomplete');
     $ctr->post('/file/create', 'createFile')->bind('file/create');
     $ctr->post('/file/delete', 'deleteFile')->bind('file/delete');
     $ctr->post('/file/duplicate', 'duplicateFile')->bind('file/duplicate');
     $ctr->post('/file/rename', 'renameFile')->bind('file/rename');
     $ctr->post('/folder/create', 'createFolder')->bind('createfolder');
     $ctr->post('/folder/rename', 'renameFolder')->bind('renamefolder');
     $ctr->post('/folder/remove', 'removeFolder')->bind('removefolder');
     $ctr->get('/recordbrowser', 'recordBrowser')->bind('recordbrowser');
 }
Ejemplo n.º 23
0
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     // *******
     // ** Signup member
     // *******
     $controllers->get('signup.html', function () use($app) {
         $form = $app['form.factory']->create(new \Aperophp\Form\Signup());
         return $app['twig']->render('member/signup.html.twig', array('form' => $form->createView()));
     })->bind('_signupmember');
     // *******
     // *******
     // ** Create member
     // *******
     $controllers->post('create.html', function (Request $request) use($app) {
         $form = $app['form.factory']->create(new \Aperophp\Form\Signup());
         $form->bindRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             // TODO save member in database.
             var_dump($data);
             die;
         }
         return $app['twig']->render('member/signup.html.twig', array('form' => $form->createView()));
     })->bind('_createmember');
     // *******
     return $controllers;
 }
Ejemplo n.º 24
0
 public function connect(Application $app)
 {
     $user = new ControllerCollection(new Route());
     $user->get('/', "user.controller:show");
     $user->match('/login', "user.controller:login")->method('POST|GET');
     $user->match('/show', "user.controller:show")->method('GET|POST');
     $user->match('/add', "user.controller:add")->method('POST|GET');
     $user->match('/logout', "user.controller:logout")->method('GET');
     return $user;
 }
Ejemplo n.º 25
0
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     // *******
     // ** Homepage
     // *******
     $controllers->get('/', function () use($app) {
         return $app['twig']->render('index.html.twig');
     });
     // *******
     // *******
     // ** Add a drink
     // *******
     $controllers->get('apero/new.html', function () use($app) {
         return $app['twig']->render('apero/new.html.twig');
     });
     // *******
     return $controllers;
 }
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $supervisor = new API();
     $servers = (require_once __DIR__ . '/../../config.php');
     $controllers->get('/{server}', function ($server) use($supervisor, $app) {
         //$server_ip = $servers[$server]['ip'];
         $services = $supervisor->getAllProcessInfo('127.0.0.1');
         return $app->json($services);
     });
     $controllers->post('/{server}/{service}', function (Request $request, $server, $service) use($supervisor, $servers, $app) {
         $server_ip = $servers[$server]['ip'];
         if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) {
             $data = json_decode($request->getContent(), true);
         } else {
             return false;
         }
         $result = false;
         // Get the current state of the service
         $current_service = $supervisor->getProcessInfo('127.0.0.1', $service);
         if (isset($current_service['error'])) {
             $result = $current_service;
         } else {
             if (!(bool) $data['running'] && $current_service['state'] == $supervisor::STATE_RUNNING) {
                 $result = $supervisor->stopProcess('127.0.0.1', $service);
             } else {
                 if ((bool) $data['running'] && $current_service['state'] != $supervisor::STATE_RUNNING) {
                     $result = $supervisor->startProcess('127.0.0.1', $service);
                 }
             }
         }
         if (!$result) {
             $result = array('error' => array('code' => '', 'msg' => 'Error getting details for ' . $service . ' from ' . $server_ip));
         }
         return $app->json($result);
     });
     $controllers->get('/{server}/{service}', function ($server, $service) use($supervisor, $servers, $app) {
         $server_ip = $servers[$server]['ip'];
         return $app->json($supervisor->getProcessInfo('127.0.0.1', $service));
     });
     return $controllers;
 }
Ejemplo n.º 27
0
 public function testMount()
 {
     $mounted = new ControllerCollection(new Route());
     $mounted->get('/{name}', function ($name) {
         return new Response($name);
     });
     $app = new Application();
     $app->mount('/hello', $mounted);
     $response = $app->handle(Request::create('/hello/Silex'));
     $this->assertEquals('Silex', $response->getContent());
 }
 /**
  * @param ControllerCollection $routing
  */
 public static function createRouting(ControllerCollection $routing)
 {
     $routing->get('/observer-mode/rest/consumer/version', [new static(), 'getVersionAction']);
     $routing->get('/observer-mode/rest/consumer/getGameMetaData/{region}/{gameId}/{token}/token', [new static(), 'getGameMetaDataAction']);
     $routing->get('/observer-mode/rest/consumer/getLastChunkInfo/{region}/{gameId}/{chunkId}/token', [new static(), 'getLastChunkInfoAction']);
     $routing->get('/observer-mode/rest/consumer/getGameDataChunk/{region}/{gameId}/{chunkId}/token', [new static(), 'getGameDataChunkAction']);
     $routing->get('/observer-mode/rest/consumer/getKeyFrame/{region}/{gameId}/{keyframeId}/token', [new static(), 'getKeyFrameAction']);
     $routing->get('/observer-mode/rest/consumer/endOfGameStats/{region}/{gameId}/null', [new static(), 'getEndOfGameStatsAction']);
 }
Ejemplo n.º 29
0
 protected function addHomeRoutes(ControllerCollection $ctrl)
 {
     // Home : a list of elements
     $ctrl->get('/', [$this, 'home'])->value('page', 1);
     $ctrl->get('/{page}', [$this, 'home'])->assert('page', '\\d+');
     // ...filtered by one tag
     $ctrl->get('/tag-{tags}/{page}', [$this, 'home'])->value('page', 1)->assert('page', '\\d+');
     // ...filtered by multiple tags
     $ctrl->get('/tags-{tags}/{page}', [$this, 'home'])->value('page', 1)->assert('page', '\\d+');
     // ...filtered by year
     $ctrl->get('/year-{year}/{page}', [$this, 'home'])->value('page', 1)->assert('page', '\\d+')->assert('year', '\\d{4}');
     // ...filtered by year and month
     $ctrl->get('/year-{year}/month-{month}/{page}', [$this, 'home'])->value('page', 1)->assert('page', '\\d+')->assert('year', '\\d{4}')->assert('month', '\\d{1,2}');
 }
Ejemplo n.º 30
0
 /**
  * Returns routes to connect to the application.
  *
  * @param \Silex\ControllerCollection $c
  */
 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('', 'overview')->bind('extend');
     $c->get('/check', 'check')->bind('check');
     $c->get('/update', 'update')->bind('update');
     $c->get('/install', 'install')->bind('install');
     $c->get('/uninstall', 'uninstall')->bind('uninstall');
     $c->get('/installed', 'installed')->bind('installed');
     $c->get('/installAll', 'installAll')->bind('installAll');
     $c->get('/installPackage', 'installPackage')->bind('installPackage');
     $c->get('/installInfo', 'installInfo')->bind('installInfo');
     $c->get('/packageInfo', 'packageInfo')->bind('packageInfo');
     $c->get('/generateTheme', 'generateTheme')->bind('generateTheme');
 }