Вы находитесь на странице: 1из 4

Write your rst ownCloud App

in 60 minutes

ownCloud, Inc. 10 Foster Road Lexington, MA 02421 United States

mail: info@owncloud.com phone: +1 (877) 394-2030 https://www.owncloud.com

Write your rst ownCloud App in 60min


ownCloud is a software that can be used to replace proprietary cloud services like Google Drive, Dropbox or box.net. Users can host an ownCloud installation on own hardware or at a provider that offers ownCloud hosting. ownCloud can also run on most basic webspaces that support PHP without the need for special congurations. ownCloud is suitable for home users and big organisations and is available under the AGPL license as free software. It is developed by an open and friendly worldwide community of developers. Professional enterprise support and services around ownCloud is delivered by ownCloud Inc. Ehe core feature is to store, sync and share you les and documents and access them from all you devices cross platform. But ownCloud is more than just a modern le sync and share solution. ownCloud support an concept called ownCloud applications. An application is a plugin or extension that can run on top of ownCloud and provide additional features and functionallities. Example for apps that are already part of ownCloud are the media player app, the calendar or the contacts app. ownCloud is a platform for HTML5 applications and all kind of webservice that users want to host and run under own control. on proprietary services like gmail to provide you with a web-mail interface, or you want your own link shortening service running on your own machine or you want your own application to manage your DVD collection. You can easily write your own ownCloud application to implement this features. Your ownCloud application can provide an HTML5 interface or an RESTfull API to provide you with the webservice you want. Another reason to write an ownCloud application is to build a syncing and sharing backend for an existing application. Example are: You want to extend a photo management desktop application with the posibility to share photos with others. You want extend your game to store a shared high score list on a central place. You want to extend you notes application or RSS reader to sync data and status between different devices. Writing ownCloud applications is easy and fun. So please try it if you have an idea for a free service that should run on top of ownCloud.

What do I have to know?


PHP You should know how to code some basic PHP and you need some basic understanding how the web and webservers work. The PHP syntax is similar to C or C++ and a lot of other languages so it should be easy to learn. ownCloud has a powerful framework to help you with thing like usermanagement or templating. HTML You need some basic HTML and CSS knowledge to develop the userinterface of your application. ownCloud provides you with some basic functionallity to create conguration dialogs or other basic userinterface elements. ownCloud is using jQuery so we suggest that you look into it if you want to create a rich HTML5 webinterface as part of your application. SQL ownCloud has basic functionallity to read and write basic data to the database or to the lesystem. You need some SQL knowledge if you want to work with more complex data structures in your application. This is optional and depends on the type of application you want to create. ownCloud API The ownCloud core provides a stable public API for ownCloud application developers. You should make yourself familiar with the basic calls that are required to be used like registering you application, loading and saving of conguration and other basic functionallities.

How difficult is it?


Writing ownCloud applications is easy. You need some basic PHP and HTML knowledge to write your rst ownCloud application. Depending on the typ of application you want to build, some JavaScript and SQL knowledge is also useful. ownCloud has a very open and friendly community so you can always get help from experts via mailinglists, IRC chat channels or the forum.

Why should you develop an app for ownCloud ?


Everybody is welcome to join the ownCloud core developer community to help to improve the core features and help to push ownCloud forward. But even if you dont want to do this there are reason why you should consider to write an ownCloud application. Perhaps you are missing a feature and want to extend ownCloud to suport it. Perhaps you dont want to rely

Page 1 of 2

YOUR CLOUD, YOUR DATA, YOUR WAY!

How to start
All the ownCloud code is located at gitorious.org [7] In the apps repository are a lot of application located that you can use to look into and learn how an ownCloud application is structured. [1] Before you start, please check if there already is a similar app you could contribute to. For the beginning we suggest to use the application template as a starting point for the development. [2] You can always ask questions on the mailinglists, forum or the chat channel. You nd all the possible ways to contact the core team here: [3]

l10n Put your translations into this folder if you want to support more than english. As soon as the translation detects a l10n folder it knows that this program is translatable. You nd more information about the translation system here [6] lib Please put you application logic, classes and functions into php les in this folder. ownCloud uses the MVC principle. The libraries represent the model. Basically all data should be handled here so the php les the user calls only interact with the library. If you have a look at the lib folder in, for example the contacts app, you will see three les: addressbook. php, hooks.php and connector_sabre.php. addressbook.php contains all methods that are required for handling addresses. We mostly use the classes as namespaces and write static functions, real OOP with dynamicaly instansiated objects is only used if it is useful. templates Templates for your userinterface should go into this folder. ownCloud has its own template system. The templates are php les that are included by OC_Template. Having a look at an example le should show you everything you need to know. The variables are assigned by using $tmpl>assign(name, value);, You nd more information here [4] The API You nd the complete API documentation here [4] The most important calls are: OCP\App::addNavigationEntry This adds an navigation of your application to the main navigation on the left. You usually call this in app.php

OCP\App::setActiveNavigationEntry This calls activated a navigation entry. You do this when inside your application OCP\App::registerPersonal You can use this call to register an personal settings section on the user settings page. OCP\App::registerAdmin You can use this call to register an admin settings section on the main admin page. OCP\Cong::getUserValue Use this call to to read a setting for the currently logged in user from the settings store. OCP\Cong::setUserValue Use this call to to write a setting for the currently logged in user to the settings store. OCP\DB::prepare Prepare an SQL statement for execution. OCP\User::isLoggedIn Check if a user is currently logged in. OCP\Util::addscript Load an additional JS script OCP\Util::addStyle Load an additional CSS style

The directory structure


ownCloud applications have to be structured in a specic way to work. The recommended directory structure is: ajax a directory for the ajax call controler les if needed in your application. appinfo The info.xml and the app.php are located in this folder. The most important le is app.php. ownCloud will call this le everytime it runs, so this is the place where you can register your navigation entries or connect signals and slots. You can also put a database. xml into this folder if needed. css The addtional stylesheets of this application are located here. img All the needed images should be located in this folder. js You can put you Javascript les here. The JS libraries we use are jQuery and Torch. You can add scripts to your pages using OCP\Util::addscript. Scripts can be added this way in either appinfo/app.php or in your apps individual PHP scripts.

[1] https://github.com/owncloud/apps [2] https://github.com/owncloud/apps/ tree/master/appframework [3] http://owncloud.org/contact/ [4] http://owncloud.org/dev/apps/ getting-started/ [5] http://api.owncloud.org [6] http://owncloud.org/dev/translation/ [7] https://github.com/owncloud

Page 2 of 2

YOUR CLOUD, YOUR DATA, YOUR WAY!

ownCloud, Inc. 10 Foster Road Lexington, MA 02421 United States mail: info@owncloud.com phone: +1 (877) 394-2030 https://www.owncloud.com

Вам также может понравиться