summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-17 12:14:34 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-17 12:17:09 +0100
commit9c45ab49a152545991ec324bfdc4f41292e91bad (patch)
tree946a502083a35087fecd8b04e102d246985291d5
parentd96b97043b2fa7ba4d676c1d7b44f4aa5e58c8ee (diff)
downloadnextcloud-server-9c45ab49a152545991ec324bfdc4f41292e91bad.tar.gz
nextcloud-server-9c45ab49a152545991ec324bfdc4f41292e91bad.zip
Use a closure for the files app entry and deprecate old methods
-rw-r--r--apps/files/appinfo/app.php39
-rw-r--r--lib/private/app.php27
-rw-r--r--lib/public/app.php17
3 files changed, 38 insertions, 45 deletions
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php
index 87791e2558e..528156e1a28 100644
--- a/apps/files/appinfo/app.php
+++ b/apps/files/appinfo/app.php
@@ -1,32 +1,37 @@
<?php
-$l = \OC::$server->getL10N('files');
-OCP\App::registerAdmin('files', 'admin');
+\OCP\App::registerAdmin('files', 'admin');
-OCP\App::addNavigationEntry(array("id" => "files_index",
- "order" => 0,
- "href" => OCP\Util::linkTo("files", "index.php"),
- "icon" => OCP\Util::imagePath("core", "places/files.svg"),
- "name" => $l->t("Files")));
+\OC::$server->getNavigationManager()->add(function () {
+ $l = \OC::$server->getL10N('files');
+ return [
+ 'id' => 'files_index',
+ 'order' => 0,
+ 'href' => \OCP\Util::linkTo('files', 'index.php'),
+ 'icon' => \OCP\Util::imagePath('core', 'places/files.svg'),
+ 'name' => $l->t('Files'),
+ ];
+});
\OC::$server->getSearch()->registerProvider('OC\Search\Provider\File', array('apps' => array('files')));
-$templateManager = OC_Helper::getFileTemplateManager();
+$templateManager = \OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('text/html', 'core/templates/filetemplates/template.html');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
-\OCA\Files\App::getNavigationManager()->add(
- array(
- "id" => 'files',
- "appname" => 'files',
- "script" => 'list.php',
- "order" => 0,
- "name" => $l->t('All files')
- )
-);
+\OCA\Files\App::getNavigationManager()->add(function () {
+ $l = \OC::$server->getL10N('files');
+ return [
+ 'id' => 'files',
+ 'appname' => 'files',
+ 'script' => 'list.php',
+ 'order' => 0,
+ 'name' => $l->t('All files'),
+ ];
+});
\OC::$server->getActivityManager()->registerExtension(function() {
return new \OCA\Files\Activity(
diff --git a/lib/private/app.php b/lib/private/app.php
index 9ae4ae30d74..f51736a59a8 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -319,29 +319,6 @@ class OC_App {
}
/**
- * adds an entry to the navigation
- *
- * @param array $data array containing the data
- * @return bool
- *
- * This function adds a new entry to the navigation visible to users. $data
- * is an associative array.
- * The following keys are required:
- * - id: unique id for this entry ('addressbook_index')
- * - href: link to the page
- * - name: Human readable name ('Addressbook')
- *
- * The following keys are optional:
- * - icon: path to the icon of the app
- * - order: integer, that influences the position of your application in
- * the navigation. Lower values come first.
- */
- public static function addNavigationEntry($data) {
- OC::$server->getNavigationManager()->add($data);
- return true;
- }
-
- /**
* marks a navigation entry as active
*
* @param string $id id of the entry
@@ -350,6 +327,8 @@ class OC_App {
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
* highlighting the current position of the user.
+ *
+ * @deprecated Use \OC::$server->getNavigationManager()->setActiveEntry() instead
*/
public static function setActiveNavigationEntry($id) {
OC::$server->getNavigationManager()->setActiveEntry($id);
@@ -380,6 +359,8 @@ class OC_App {
*
* This function returns the id of the active navigation entry (set by
* setActiveNavigationEntry
+ *
+ * @deprecated Use \OC::$server->getNavigationManager()->getActiveEntry() instead
*/
public static function getActiveNavigationEntry() {
return OC::$server->getNavigationManager()->getActiveEntry();
diff --git a/lib/public/app.php b/lib/public/app.php
index bef4e96ae02..736c2b64c7d 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -49,8 +49,6 @@ class App {
/**
* Adds an entry to the navigation
- * @param array $data containing the data
- * @return boolean
*
* This function adds a new entry to the navigation visible to users. $data
* is an associative array.
@@ -62,10 +60,17 @@ class App {
* The following keys are optional:
* - icon: path to the icon of the app
* - order: integer, that influences the position of your application in
- * the navigation. Lower values come first.
+ * the navigation. Lower values come first.
+ *
+ * @param array $data containing the data
+ * @return boolean
+ *
+ * @deprecated Use \OC::$server->getNavigationManager()->add() instead to
+ * register a closure, this helps to speed up all requests against ownCloud
*/
- public static function addNavigationEntry( $data ) {
- return \OC_App::addNavigationEntry( $data );
+ public static function addNavigationEntry($data) {
+ \OC::$server->getNavigationManager()->add($data);
+ return true;
}
/**
@@ -76,6 +81,8 @@ class App {
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
* highlighting the current position of the user.
+ *
+ * @deprecated Use \OC::$server->getNavigationManager()->setActiveEntry() instead
*/
public static function setActiveNavigationEntry( $id ) {
return \OC_App::setActiveNavigationEntry( $id );