diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-20 23:33:51 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-21 00:31:48 +0100 |
commit | 964383cc7a74078dab9e80aeed2c226992087c1c (patch) | |
tree | a2ed04b6a81f389e2606b9c3b6da2ec8dc1a853a /appinfo/routes.php | |
parent | ef2af010a63bfcf511cdf648e9358a3956d97739 (diff) |
welcome in the age of newness
Diffstat (limited to 'appinfo/routes.php')
-rw-r--r-- | appinfo/routes.php | 201 |
1 files changed, 24 insertions, 177 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 767e59f09..ab9e173fc 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,206 +1,53 @@ <?php + /** -* ownCloud - News app +* ownCloud - News * +* @author Alessandro Cosentino * @author Bernhard Posselt -* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> +* @copyright 2012 Alessandro Cosentino cosenal@gmail.com +* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details. * -* This file is licensed under the Affero General Public License version 3 or later. -* See the COPYING-README file +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ namespace OCA\News; -require_once \OC_App::getAppPath('news') . '/appinfo/bootstrap.php'; - -/** - * Shortcut for calling a controller method and printing the result - * @param string $controllerName: the name of the controller under which it is - * stored in the DI container - * @param string $methodName: the method that you want to call - * @param array $urlParams: an array with variables extracted from the routes - * @param bool $disableAdminCheck: disables the check for adminuser rights - * @param bool $isAjax: if the request is an ajax request - */ -function callController($controllerName, $methodName, $urlParams, $disableAdminCheck=true, - $isAjax=false){ - $container = createDIContainer(); - - // run security checks - $security = $container['Security']; - runSecurityChecks($security, $isAjax, $disableAdminCheck); - - // call the controller and render the page - $controller = $container[$controllerName]; - $response = $controller->$methodName($urlParams); - echo $response->render(); -} - +use \OCA\AppFramework\App; -/** - * Shortcut for calling an ajax controller method and printing the result - * @param string $controllerName: the name of the controller under which it is - * stored in the DI container - * @param string $methodName: the method that you want to call - * @param array $urlParams: an array with variables extracted from the routes - * @param bool $disableAdminCheck: disables the check for adminuser rights - */ -function callAjaxController($controllerName, $methodName, $urlParams, $disableAdminCheck=true){ - callController($controllerName, $methodName, $urlParams, $disableAdminCheck, true); -} +use \OCA\News\DependencyInjection\DIContainer; /** - * Runs the security checks and exits on error - * @param Security $security: the security object - * @param bool $isAjax: if true, the ajax checks will be run, otherwise the normal - * checks - * @param bool $disableAdminCheck: disables the check for adminuser rights - */ -function runSecurityChecks($security, $isAjax=false, $disableAdminCheck=true){ - if($disableAdminCheck){ - $security->setIsAdminCheck(false); - } - - if($isAjax){ - $security->runAJAXChecks(); - } else { - $security->runChecks(); - } -} - - -/************************* - * Define your routes here + * Webinterface */ - -/** - * Normal Routes - */ -$this->create('news_index', '/')->action( +$this->create('news_index', '/')->get()->action( function($params){ - callController('NewsController', 'index', $params, true); + //App::main('FolderController', 'getAll', $params, new DIContainer()); } ); -$this->create('news_index_feed', '/feed/{feedid}')->action( - function($params){ - callController('NewsController', 'index', $params, true); - } -); -$this->create('news_export_opml', '/export/opml')->action( +$this->create('news_folders', '/folders')->get()->action( function($params){ - callController('NewsController', 'exportOPML', $params, true); + App::main('FolderController', 'getAll', $params, new DIContainer()); } ); -/** - * AJAX Routes - */ -$this->create('news_ajax_init', '/ajax/init')->action( - function($params){ - callAjaxController('NewsAjaxController', 'init', $params); - } -); - -$this->create('news_ajax_setshowall', '/ajax/setshowall')->action( - function($params){ - callAjaxController('NewsAjaxController', 'setShowAll', $params); - } -); - - -/** - * Folders - */ -$this->create('news_ajax_collapsefolder', '/ajax/collapsefolder')->action( - function($params){ - callAjaxController('NewsAjaxController', 'collapseFolder', $params); - } -); - -$this->create('news_ajax_changefoldername', '/ajax/changefoldername')->action( - function($params){ - callAjaxController('NewsAjaxController', 'changeFolderName', $params); - } -); - -$this->create('news_ajax_createfolder', '/ajax/createfolder')->action( - function($params){ - callAjaxController('NewsAjaxController', 'createFolder', $params); - } -); - -$this->create('news_ajax_deletefolder', '/ajax/deletefolder')->action( - function($params){ - callAjaxController('NewsAjaxController', 'deleteFolder', $params); - } -); - - -/** - * Feeds - */ -$this->create('news_ajax_loadfeed', '/ajax/loadfeed')->action( - function($params){ - callAjaxController('NewsAjaxController', 'loadFeed', $params); - } -); - -$this->create('news_ajax_deletefeed', '/ajax/deletefeed')->action( - function($params){ - callAjaxController('NewsAjaxController', 'deleteFeed', $params); - } -); - -$this->create('news_ajax_movefeedtofolder', '/ajax/movefeedtofolder')->action( - function($params){ - callAjaxController('NewsAjaxController', 'moveFeedToFolder', $params); - } -); - -$this->create('news_ajax_updatefeed', '/ajax/updatefeed')->action( - function($params){ - callAjaxController('NewsAjaxController', 'updateFeed', $params); - } -); - -$this->create('news_ajax_createfeed', '/ajax/createfeed')->action( - function($params){ - callAjaxController('NewsAjaxController', 'createFeed', $params); - } -); - - -/** - * Items - */ -$this->create('news_ajax_setitemstatus', '/ajax/setitemstatus')->action( - function($params){ - callAjaxController('NewsAjaxController', 'setItemStatus', $params); - } -); - -$this->create('news_ajax_setallitemsread', '/ajax/setallitemsread')->action( - function($params){ - callAjaxController('NewsAjaxController', 'setAllItemsRead', $params); - } -); - - -/** - * Import stuff - */ -$this->create('news_ajax_importOPML', '/import')->action( - function($params){ - callAjaxController('NewsAjaxController', 'uploadOPML', $params); - } -); - /** * External API |