ported the oc_app calls

This commit is contained in:
Frank Karlitschek 2012-05-02 00:50:26 +02:00
parent c94f39b488
commit 2fe646dcec
35 changed files with 207 additions and 52 deletions

4
apps/admin_dependencies_chk/appinfo/app.php Normal file → Executable file
View File

@ -1,9 +1,9 @@
<?php
$l=OC_L10N::get('admin_dependencies_chk');
OC_App::register( array(
OCP\App::register( array(
'order' => 14,
'id' => 'admin_dependencies_chk',
'name' => 'Owncloud Install Info' ));
OC_APP::registerAdmin('admin_dependencies_chk','settings');
OCP\App::registerAdmin('admin_dependencies_chk','settings');

2
apps/admin_dependencies_chk/settings.php Normal file → Executable file
View File

@ -77,7 +77,7 @@ $modules[] =array(
foreach($modules as $key => $module) {
$enabled = false ;
foreach($module['modules'] as $app) {
if(OC_App::isEnabled($app) || $app=='core'){
if(OCP\App::isEnabled($app) || $app=='core'){
$enabled = true;
}
}

View File

@ -22,7 +22,7 @@
*/
OC_APP::registerAdmin('admin_migrate','settings');
OCP\App::registerAdmin('admin_migrate','settings');
// add settings page to navigation
$entry = array(

View File

@ -10,12 +10,12 @@
OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php';
OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php';
OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
OCP\App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
$l = new OC_l10n('bookmarks');
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
OCP\App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
OC_App::registerPersonal('bookmarks', 'settings');
OCP\App::registerPersonal('bookmarks', 'settings');
OCP\Util::addscript('bookmarks','bookmarksearch');
OC_Search::registerProvider('OC_Search_Provider_Bookmarks');

View File

@ -27,7 +27,7 @@
OCP\User::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
OCP\App::setActiveNavigationEntry( 'bookmarks_index' );
OCP\Util::addscript('bookmarks','bookmarks');
OCP\Util::addStyle('bookmarks', 'bookmarks');

View File

@ -11,15 +11,15 @@ OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser'
OCP\Util::addscript('calendar','loader');
OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min");
OCP\Util::addStyle("3rdparty", "chosen/chosen");
OC_App::register( array(
OCP\App::register( array(
'order' => 10,
'id' => 'calendar',
'name' => 'Calendar' ));
OC_App::addNavigationEntry( array(
OCP\App::addNavigationEntry( array(
'id' => 'calendar_index',
'order' => 10,
'href' => OCP\Util::linkTo( 'calendar', 'index.php' ),
'icon' => OCP\Util::imagePath( 'calendar', 'icon.svg' ),
'name' => $l->t('Calendar')));
OC_App::registerPersonal('calendar', 'settings');
OCP\App::registerPersonal('calendar', 'settings');
OC_Search::registerProvider('OC_Search_Provider_Calendar');

View File

@ -52,7 +52,7 @@ OCP\Util::addscript('', 'jquery.multiselect');
OCP\Util::addStyle('', 'jquery.multiselect');
OCP\Util::addscript('contacts','jquery.multi-autocomplete');
OCP\Util::addscript('','oc-vcategories');
OC_App::setActiveNavigationEntry('calendar_index');
OCP\App::setActiveNavigationEntry('calendar_index');
$tmpl = new OC_Template('calendar', 'calendar', 'user');
$tmpl->assign('eventSources', $eventSources);
$tmpl->assign('categories', $categories);

View File

@ -2,7 +2,7 @@
class OC_Search_Provider_Calendar extends OC_Search_Provider{
function search($query){
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
if(count($calendars)==0 || !OC_App::isEnabled('calendar')){
if(count($calendars)==0 || !OCP\App::isEnabled('calendar')){
//return false;
}
$results=array();

View File

@ -34,7 +34,7 @@ function debug($msg) {
OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::DEBUG);
}
$view = OC_App::getStorage('contacts');
$view = OCP\App::getStorage('contacts');
$tmpfile = md5(rand());
// If it is a Drag'n'Drop transfer it's handled here.

View File

@ -9,12 +9,12 @@ OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser'
OC_HOOK::connect('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
OC_HOOK::connect('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');
OC_App::register( array(
OCP\App::register( array(
'order' => 10,
'id' => 'contacts',
'name' => 'Contacts' ));
OC_App::addNavigationEntry( array(
OCP\App::addNavigationEntry( array(
'id' => 'contacts_index',
'order' => 10,
'href' => OCP\Util::linkTo( 'contacts', 'index.php' ),
@ -22,6 +22,6 @@ OC_App::addNavigationEntry( array(
'name' => OC_L10N::get('contact')->t('Contacts') ));
OC_APP::registerPersonal('contacts','settings');
OCP\App::registerPersonal('contacts','settings');
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OC_Search_Provider_Contacts');

View File

@ -19,7 +19,7 @@ if(is_writable('import_tmp/')){
}
$view = $file = null;
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
$view = OC_App::getStorage('contacts');
$view = OCP\App::getStorage('contacts');
$file = $view->file_get_contents('/' . $_POST['file']);
} else {
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);

View File

@ -19,7 +19,7 @@ $contacts = OC_Contacts_VCard::all($ids);
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
// Load the files we need
OC_App::setActiveNavigationEntry( 'contacts_index' );
OCP\App::setActiveNavigationEntry( 'contacts_index' );
// Load a specific user?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;

View File

@ -53,7 +53,7 @@ class OC_Contacts_App {
$vcard = OC_VObject::parse($card['carddata']);
// Try to fix cards with missing 'N' field from pre ownCloud 4. Hot damn, this is ugly...
if(!is_null($vcard) && !$vcard->__isset('N')) {
$appinfo = OC_App::getAppInfo('contacts');
$appinfo = OCP\App::getAppInfo('contacts');
if($appinfo['version'] >= 5) {
OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG);
}

View File

@ -2,7 +2,7 @@
class OC_Search_Provider_Contacts extends OC_Search_Provider{
function search($query){
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){
// if(count($calendars)==0 || !OCP\App::isEnabled('contacts')){
// //return false;
// }
// NOTE: Does the following do anything

View File

@ -245,8 +245,8 @@ class OC_Contacts_VCard{
// Add product ID is missing.
$prodid = trim($vcard->getAsString('PRODID'));
if(!$prodid) {
$appinfo = OC_App::getAppInfo('contacts');
$appversion = OC_App::getAppVersion('contacts');
$appinfo = OCP\App::getAppInfo('contacts');
$appversion = OCP\App::getAppVersion('contacts');
$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN';
$vcard->setString('PRODID', $prodid);
}

View File

@ -24,12 +24,12 @@
OC::$CLASSPATH['OC_External'] = 'apps/external/lib/external.php';
OCP\Util::addStyle( 'external', 'style');
OC_APP::registerAdmin('external', 'settings');
OCP\App::registerAdmin('external', 'settings');
OC_App::register(array('order' => 70, 'id' => 'external', 'name' => 'External'));
OCP\App::register(array('order' => 70, 'id' => 'external', 'name' => 'External'));
$sites = OC_External::getSites();
for ($i = 0; $i < sizeof($sites); $i++) {
OC_App::addNavigationEntry(
OCP\App::addNavigationEntry(
array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OCP\Util::imagePath('external', 'external.png'), 'name' => $sites[$i][0]));
}

View File

@ -33,7 +33,7 @@ if (isset($_GET['id'])) {
$sites = OC_External::getSites();
if (sizeof($sites) >= $id) {
$url = $sites[$id - 1][1];
OC_App::setActiveNavigationEntry('external_index' . $id);
OCP\App::setActiveNavigationEntry('external_index' . $id);
$tmpl = new OC_Template('external', 'frame', 'user');
$tmpl->assign('url', $url);

View File

@ -49,7 +49,7 @@ if($_POST) {
$maxZipInputSize = OCP\Util::humanFileSize(OC_Config::getValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB')));
$allowZipDownload = intval(OC_Config::getValue('allowZipDownload', true));
OC_App::setActiveNavigationEntry( "files_administration" );
OCP\App::setActiveNavigationEntry( "files_administration" );
$tmpl = new OC_Template( 'files', 'admin' );
$tmpl->assign( 'htaccessWorking', $htaccessWorking );

View File

@ -3,8 +3,8 @@
$l=OC_L10N::get('files');
OC_App::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
OCP\App::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
OC_Search::registerProvider('OC_Search_Provider_File');

View File

@ -34,7 +34,7 @@ OCP\Util::addscript( 'files', 'fileactions' );
if(!isset($_SESSION['timezone'])){
OCP\Util::addscript( 'files', 'timezone' );
}
OC_App::setActiveNavigationEntry( "files_index" );
OCP\App::setActiveNavigationEntry( "files_index" );
// Load the files
$dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
// Redirect if directory does not exist

View File

@ -16,4 +16,4 @@ if(!isset($_SESSION['enckey']) and OCP\User::isLoggedIn()){//force the user to r
exit();
}
OC_App::registerAdmin('files_encryption', 'settings');
OCP\App::registerAdmin('files_encryption', 'settings');

View File

@ -3,7 +3,7 @@
require_once('apps/files_sharing/sharedstorage.php');
OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
OC_APP::registerAdmin('files_sharing', 'settings');
OCP\App::registerAdmin('files_sharing', 'settings');
OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
OC_Hook::connect("OC_Filesystem", "post_write", "OC_Share", "updateItem");

View File

@ -26,7 +26,7 @@ require_once('lib_share.php');
OCP\User::checkLoggedIn();
OC_Util::checkAppEnabled('files_sharing');
OC_App::setActiveNavigationEntry("files_sharing_list");
OCP\App::setActiveNavigationEntry("files_sharing_list");
OCP\Util::addscript("files_sharing", "list");

View File

@ -3,12 +3,12 @@
require_once('apps/files_versions/versions.php');
// Add an entry in the app list
OC_App::register( array(
OCP\App::register( array(
'order' => 10,
'id' => 'files_versions',
'name' => 'Versioning' ));
OC_APP::registerAdmin('files_versions', 'settings');
OCP\App::registerAdmin('files_versions', 'settings');
OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals

View File

@ -29,12 +29,12 @@ OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.p
$l = OC_L10N::get('gallery');
OC_App::register(array(
OCP\App::register(array(
'order' => 20,
'id' => 'gallery',
'name' => 'Pictures'));
OC_App::addNavigationEntry( array(
OCP\App::addNavigationEntry( array(
'id' => 'gallery_index',
'order' => 20,
'href' => OCP\Util::linkTo('gallery', 'index.php'),

View File

@ -25,7 +25,7 @@
OCP\User::checkLoggedIn();
OC_Util::checkAppEnabled('gallery');
OC_App::setActiveNavigationEntry( 'gallery_index' );
OCP\App::setActiveNavigationEntry( 'gallery_index' );
if (!file_exists(OC_Config::getValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) {
mkdir(OC_Config::getValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery');

View File

@ -25,10 +25,10 @@ $l=OC_L10N::get('media');
require_once('apps/media/lib_media.php');
OCP\Util::addscript('media','loader');
OC_APP::registerPersonal('media','settings');
OCP\App::registerPersonal('media','settings');
OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
OCP\App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
OCP\App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
OC_Search::registerProvider('OC_MediaSearchProvider');

View File

@ -39,7 +39,7 @@ OCP\Util::addscript('media','scanner');
OCP\Util::addscript('media','jquery.jplayer.min');
OCP\Util::addStyle('media','music');
OC_App::setActiveNavigationEntry( 'media_index' );
OCP\App::setActiveNavigationEntry( 'media_index' );
$tmpl = new OC_Template( 'media', 'music', 'user' );
$tmpl->printPage();

4
apps/remoteStorage/appinfo/app.php Normal file → Executable file
View File

@ -1,6 +1,6 @@
<?php
OC_App::register( array(
OCP\App::register( array(
'order' => 10,
'id' => 'remoteStorage',
'name' => 'remoteStorage compatibility' ));
OC_APP::registerPersonal('remoteStorage','settings');
OCP\App::registerPersonal('remoteStorage','settings');

View File

@ -25,7 +25,7 @@ require_once('apps/user_ldap/lib_ldap.php');
require_once('apps/user_ldap/user_ldap.php');
require_once('apps/user_ldap/group_ldap.php');
OC_APP::registerAdmin('user_ldap','settings');
OCP\App::registerAdmin('user_ldap','settings');
// define LDAP_DEFAULT_PORT
define('OC_USER_BACKEND_LDAP_DEFAULT_PORT', 389);
@ -44,4 +44,3 @@ $entry = array(
'href' => OCP\Util::linkTo( 'user_ldap', 'settings.php' ),
'name' => 'LDAP'
);
// OC_App::addNavigationSubEntry( "core_users", $entry);

View File

@ -21,8 +21,8 @@
*
*/
OC_APP::registerPersonal( 'user_migrate', 'settings' );
OC_APP::registerAdmin( 'user_migrate', 'admin' );
OCP\App::registerPersonal( 'user_migrate', 'settings' );
OCP\App::registerAdmin( 'user_migrate', 'admin' );
OCP\Util::addscript( 'user_migrate', 'export');
// add settings page to navigation

View File

@ -17,7 +17,7 @@ if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'='))
OCP\Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OCP\Util::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName));
OCP\Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OCP\Util::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName));
OC_APP::registerPersonal('user_openid','settings');
OCP\App::registerPersonal('user_openid','settings');
require_once 'apps/user_openid/user_openid.php';

2
apps/user_webfinger/appinfo/app.php Normal file → Executable file
View File

@ -1,5 +1,5 @@
<?php
OC_App::register( array(
OCP\App::register( array(
'order' => 11,
'id' => 'user_webfinger',
'name' => 'Webfinger' ));

2
apps/user_webfinger/webfinger.php Normal file → Executable file
View File

@ -61,7 +61,7 @@ echo "<";
<?php
$apps = OC_Appconfig::getApps();
foreach($apps as $app) {
if(OC_App::isEnabled($app)) {
if(OCP\App::isEnabled($app)) {
if(is_file(OC::$APPSROOT . '/apps/' . $app . '/appinfo/webfinger.php')) {
require($app . '/appinfo/webfinger.php');
}

156
lib/public/app.php Normal file
View File

@ -0,0 +1,156 @@
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2010 Frank Karlitschek karlitschek@kde.org
*
* 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.
*
* 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/>.
*
*/
/**
* Public interface of ownCloud for apps to use.
* App Class.
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
class App {
/**
* @brief get the user id of the user currently logged in.
* @return string uid or false
*/
public static function getUser(){
return \OC_USER::getUser();
}
/**
* @brief makes owncloud aware of this app
* @param $data array with all information
* @returns true/false
*
* This function registers the application. $data is an associative array.
* The following keys are required:
* - id: id of the application, has to be unique ('addressbook')
* - name: Human readable name ('Addressbook')
* - version: array with Version (major, minor, bugfix) ( array(1, 0, 2))
*
* The following keys are optional:
* - order: integer, that influences the position of your application in
* a list of applications. Lower values come first.
*
*/
public static function register( $data ){
return \OC_App::register( $data );
}
/**
* register an admin form to be shown
*/
public static function registerAdmin($app,$page){
return \OC_App::registerAdmin($app,$page);
}
/**
* @brief adds an entry to the navigation
* @param $data array containing the data
* @returns true/false
*
* 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 ){
return \OC_App::addNavigationEntry($data);
}
/**
* @brief Read app metadata from the info.xml file
* @param string $appid id of the app or the path of the info.xml file
* @param boolean path (optional)
* @returns array
*/
public static function getAppInfo($appid,$path=false){
return \OC_App::getAppInfo($appid,$path);
}
/**
* register a personal form to be shown
*/
public static function registerPersonal($app,$page){
return \OC_App::registerPersonal($app,$page);
}
/**
* @brief marks a navigation entry as active
* @param $id id of the entry
* @returns true/false
*
* 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.
*/
public static function setActiveNavigationEntry($id){
return \OC_App::setActiveNavigationEntry($id);
}
/**
* @brief checks whether or not an app is enabled
* @param $app app
* @returns true/false
*
* This function checks whether or not an app is enabled.
*/
public static function isEnabled( $app ){
return \OC_App::isEnabled( $app );
}
/**
* get the last version of the app, either from appinfo/version or from appinfo/info.xml
*/
public static function getAppVersion($appid){
return \OC_App::getAppVersion( $appid );
}
/**
* @param string appid
* @return OC_FilesystemView
*/
public static function getStorage($appid){
return \OC_App::getStorage( $appid );
}
}
?>