<?php /*################################################## * index.php * ------------------- * begin : September 06, 2012 * copyright : (C) 2012 Kévin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ define('PATH_TO_ROOT', '..'); require_once PATH_TO_ROOT . '/kernel/init.php'; $url_controller_mappers = array( new UrlControllerMapper('MyModuleAdminController', '`^/admin/?$`'), //Contrôleur exécuté lorsqu'il n'y a pas de paramètre new UrlControllerMapper('MyModuleHomeController', '`^/?$`') ); DispatchManager::dispatch($url_controller_mappers); ?>
<?php /*################################################## * index.php * ------------------- * begin : September 06, 2012 * copyright : (C) 2012 Kévin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ define('PATH_TO_ROOT', '..'); require_once PATH_TO_ROOT . '/kernel/init.php'; $url_controller_mappers = array( new UrlControllerMapper('MyModuleAdminController', '`^/admin/?$`'), //Contrôleur exécuté lorsqu'il n'y a pas de paramètre new UrlControllerMapper('MyModuleHomeController', '`^/?$`'), //Contrôleur exécuté avec l'url /my_module/?url/edit/2 new UrlControllerMapper('EditNewsController', '`^/edit/([0-9]+)?/?$`', array('identifier')) ); DispatchManager::dispatch($url_controller_mappers); ?>
public function execute(HTTPRequestCustom $request) { }
<?php /*################################################## * MyModuleHomeController.class.php * ------------------- * begin : September 06, 2012 * copyright : (C) 2012 Kévin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class MyModuleHomeController extends ModuleController { public function execute(HTTPRequestCustom $request) { $tpl = new StringTemplate('Voici le page d\'accueil de mon module!'); return $this->build_response($tpl); } private function build_response(View $view) { $response = new SiteDisplayResponse($view); $response->get_graphical_environment()->set_page_title('Mon premier module !'); return $response; } } ?>
<?php /*################################################## * MyModuleJSONController.class.php * ------------------- * begin : September 06, 2012 * copyright : (C) 2012 Kévin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class MyModuleJSONController extends ModuleController { public function execute(HTTPRequestCustom $request) { $data = array('Vos données'); return new JSONResponse($data); } } ?>