diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-26 15:11:29 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-26 15:11:29 +0200 |
commit | 815ab94c707e13fbbeb173b681d32c6d65850128 (patch) | |
tree | 29f06206fc7c241538be8afecd252fef1255011e /doc | |
parent | c971102dcdaeaf94d3830a46712727a4dfb1f0af (diff) |
more docs on plugins
Diffstat (limited to 'doc')
-rw-r--r-- | doc/plugins.rst | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/doc/plugins.rst b/doc/plugins.rst index 27c340f1d..76df7e071 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -6,63 +6,63 @@ General plugin infos -------------------- A plugin is in essence a seperate app. You should first read the `intro <http://doc.owncloud.org/server/master/developer_manual/app/intro/createapp.html>`_ and `tutorial <http://doc.owncloud.org/server/master/developer_manual/app/appframework/tutorial.html>`_ and create the basic files. -In addition to the basic structure you also want to make sure that the News app is enabled. To do that open :file:`appinfo/app.php` and add the following if: +In addition to the basic structure you also want to make sure that the News app is enabled. To do that open :file:`my_news_plugin/appinfo/app.php` and add the following if: .. code-block:: php - <?php - namespace MyNewsPlugin; + <?php + namespace MyNewsPlugin; - use \OCA\AppFramework\Core\API; + use \OCA\AppFramework\Core\API; - if(\OCP\App::isEnabled('news') && \OCP\App::isEnabled('appframework')){ + if(\OCP\App::isEnabled('news') && \OCP\App::isEnabled('appframework')){ - // your code here + // your code here - } + } Serverside plugin ----------------- A serverside plugin is a plugin that uses the same infrastructure to add additional features. An example would be a plugin that makes the starred entries of a user available via an interface. -Its very easy to interface with the News app. Because all Classes are registered in the :file:`dependencyinjection/dicontainer.php` it takes almost no effort to use the same infrastructure. +Its very easy to interface with the News app. Because all Classes are registered in the :file:`news/dependencyinjection/dicontainer.php` it takes almost no effort to use the same infrastructure. -Since you dont want to extend the app but use its resources, its advised that you dont inherit from the **DIContainer** class but rather include it in your own container: +Since you dont want to extend the app but use its resources, its advised that you dont inherit from the **DIContainer** class but rather include it in your own container in :file:`my_news_plugin/dependencyinjection/dicontainer.php`: .. code-block:: php - <?php - namespace OCA\MyNewsPlugin\DependencyInjection; + <?php + namespace OCA\MyNewsPlugin\DependencyInjection; - use \OCA\AppFramework\DependencyInjection\DIContainer as BaseContainer; - use \OCA\News\DependencyInjection\DIContainer as NewsContainer; + use \OCA\AppFramework\DependencyInjection\DIContainer as BaseContainer; + use \OCA\News\DependencyInjection\DIContainer as NewsContainer; - class DIContainer extends BaseContainer { + class DIContainer extends BaseContainer { - /** - * Define your dependencies in here - */ - public function __construct () { - // tell parent container about the app name - parent::__construct('my_news_plugin'); + /** + * Define your dependencies in here + */ + public function __construct () { + // tell parent container about the app name + parent::__construct('my_news_plugin'); - $this['NewsContainer'] = $this->share(function ($c) { - // make the newscontainer available in your app - return new NewsContainer(); - }); + $this['NewsContainer'] = $this->share(function ($c) { + // make the newscontainer available in your app + return new NewsContainer(); + }); - $this['YourController'] = $this->share(function ($c) { - // use the feedbusinesslayer from the news app - // you can use all defined classes but its recommended that you - // stick to the mapper and businesslayer classes since they are less - // likely to change - return new YourController($c['NewsContainer']['FeedBusinessLayer']); - }); - } + $this['YourController'] = $this->share(function ($c) { + // use the feedbusinesslayer from the news app + // you can use all defined classes but its recommended that you + // stick to the mapper and businesslayer classes since they are less + // likely to change + return new YourController($c['NewsContainer']['FeedBusinessLayer']); + }); + } - - } + + } Using this method you can basically access all the functionality of the news app in your own app. @@ -72,39 +72,39 @@ A clientside plugin could either be a new interface for the news app or a script Custom script ~~~~~~~~~~~~~ -To add a simple script create the script in the :file:`js/script.js`, then use this inside your :file:`appinfo/app.php`: +To add a simple script create the script in the :file:`my_news_plugin/js/script.js`, then use this inside your :file:`my_news_plugin/appinfo/app.php`: .. code-block:: php + + <?php + namespace MyNewsPlugin; - <?php - namespace MyNewsPlugin; - - use \OCA\AppFramework\Core\API; + use \OCA\AppFramework\Core\API; - if(\OCP\App::isEnabled('news') && \OCP\App::isEnabled('appframework')){ + if(\OCP\App::isEnabled('news') && \OCP\App::isEnabled('appframework')){ - $api = new API('my_news_plugin'); - $api->addScript('script.js'); // add a script from js/script.js + $api = new API('my_news_plugin'); + $api->addScript('script.js'); // add a script from js/script.js - } + } Inside your script you have to make sure that the News app is active. You can do that by using: .. code-block:: js + + (function ($, angular, window, undefined) { - (function ($, angular, window, undefined) { - - var document = window.document; + var document = window.document; - $(document).ready(function () { - if ($('[ng-app="News"]').length > 0) { + $(document).ready(function () { + if ($('[ng-app="News"]').length > 0) { - // your code here + // your code here - } - }); + } + }); - })(jQuery, angular, window); + })(jQuery, angular, window); Custom User interface |