Drupalgap
Entwicklung Mobiler Apps mit Drupal/Drupalgap/Cordova
Installation
Drupal 7.56 installieren
https://www.drupal.org/project/drupal/releases/7.56
folgende Module installieren und aktivieren
Drupalgap Development Snapshot 7.x.1.x installieren und aktivieren
https://github.com/signalpoint/DrupalGap/archive/7.x-1.x.zip
Unter admin/structure/services/list/drupalgap/resources die Drupal Service folgende Endpunkte aktivieren.
User
Taxonomy
Content
Drupalgap installation testen
Unter admin/config/services/drupalgap das DrupalgapSDK herunterladen ([DRUPAL_ROOT]/mobile-application).
"Test Connection" klicken und wenn alles gut läuft sollte die Meldung "The system connect test was successful, DrupalGap is configured properly!" er scheinen.
"Launch App" und Viola!
http://docs.drupalgap.org/7/Menus/Menu_Icons
Drupalgap Forms
Drupalgap Pages
Drupalgap Services
Cordova 7.0.1 und Andoid SDK installieren
Drupalgap über Cordova/Phonegap installieren
Platform Browser
Das Verzeichnis hallo/www mit dem kompletten Inhalt [DRUPAL_ROOT]/mobile-application überschreiben
Für die Browser Platform müssen keine Änderungen gemacht werden!
Der Odner hallo kann ins webroot kopiert werden und per http://localhost/hallo/platforms/browser/www
Platform Android
hallo/www/index.html
<script type="text/javascript" src="cordova.js"></script>hallo/www/app/settings.js
drupalgap.settings.mode = 'phonegap';
Wichtig: nach Änderungen im Verzeichnis hallo/www den Befehl cordova prepare ausführen um die Ressourcen nach platforms/browser/www bzw. platforms/android/assets/www zu kopieren!
Drupalgap Cheet Sheet
#Debug
Comment Service Index Hack ( gibt nur 20 absteigend sortiert zurück)!
var query = {
pagesize:150,
parameters:{ nid: },
options:{ orderby:{'created':'asc' } }
};
comment_index(query, {
success: function(comments){
console.log(comments);
});
Alternativ kann man diese Variable setzen
variable_get('services_comment_index_page_size', 20)
Facebook Modul Zeile 57: übsetzbar machen! title: t('Continue with Facebook'),
Drupalgap API Beispiele
Drupalgap Menüs, Views, Blocks Pages, Forms, Buttons,Widgets in Aktion
Drupal Drupalgap Installations Profil
installiert Drupalgap mit allen Modulen und Patches out of the box. (Drupal 7.56)
http://kimo2007.dnshome.de:8888/d7mobile/mobile-application/
http://kimo2007.dnshome.de:8888/d7mobiletemplate
Facebook Integration
FBOAuth Email patch
https://www.drupal.org/node/2744593#comment-11273727
Cordova Plugin noch nicht getestet:
https://github.com/Wizcorp/phonegap-facebook-plugin
-
Facebook App erstellen https://developers.facebook.com/apps
-
Drupalgap Facebook installieren https://github.com/signalpoint/facebook
-
In app/settings.js die FB App Einstellungen hinzufügen
drupalgap.settings.facebook = {
app_id: '123456789',
scope: 'email'
};
-
index.html editieren
Head
<script type="text/javascript" charset="utf-8" src="openfb.js"></script>
Onload/Body
<script type="text/javascript">
openFB.init({ appId: drupalgap.settings.facebook.app_id, tokenStore:window.localStorage});
</script>
-
Facbook App Einstellungen valid oAuth URL's:
(Cordova)
https://www.facebook.com/connect/login_success.html
(Browser)
http://kimo2007.dnshome.de/awrimobile/platforms/browser/www/outhcallback...
http://awri.ch/mobile/outhcallback.html
http://localhost/???/outhcallback.html
Achtung! Der Fehler oauthredirect URL https://facebook/connect/blank.html#_#
deutet auf eine fehlende oder falsche InAppbrowser Version hin:
To solve this, install either the cordova-plugin-inappbrowser@~1.1.1 or install the latest version (1.2.1) directly from github (cordova plugin add https://github.com/apache/cordova-plugin-inappbrowser.git --save).
Debug
settings,js Drupal.modules.custom['debug'] = {};
/*
* entity_primary_key - unsupported entity type (uc_addresses) - to add support, declare uc_addresses_primary_key() and have it return the primary key column name as a string
*/
/*
function uc_addresses_primary_key() {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
//alert('views_uc_addresses_primary_key');
return "aid";
}
*/
/*
* Field formatters for different custom field types
*/
/*
function pdf_field_formatter_view(entity_type, entity, field, instance,
langcode, items, display) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(entity_type);
console.log(entity);
console.log(field);
console.log(instance);
console.log(langcode);
console.log(items);
console.log(display);
console
.log("-------------------------------------------------------------");
}
function file_field_formatter_view(entity_type, entity, field, instance,
langcode, items, display) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(entity_type);
console.log(entity);
console.log(field);
console.log(instance);
console.log(langcode);
console.log(items);
console.log(display);
console
.log("-------------------------------------------------------------");
}
*/
//ERROR wenn nicht!
function file_field_widget_form(form, form_state, field, instance, langcode,
items, delta, element) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),
'debug.js');
console.log(form,'form');
console.log(form_state,'form_state');
console.log(field,'field');
console.log(instance,'instance');
console.log(langcode,'langcode');
console.log(items,'items');
console.log(delta,'delta');
console.log(element,element);
console
.log("-------------------------------------------------------------");
}
function debug_assemble_form_state_into_field(entity_type, bundle,
form_state_value, field, instance, langcode, delta, field_key, form) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(entity_type,'entity_type');
console.log(bundle,'bundle');
console.log(form_state_value,'form_state_value');
console.log(field,'field');
console.log(instance,'instance');
console.log(langcode,'langcode');
console.log(delta,'delta');
console.log(field_key,'field_key');
console.log(form,'form');
console
.log("-------------------------------------------------------------");
}
function debug_form_alter(form, form_state) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(form,"form");
console.log(form,"form_State");
console
.log("-------------------------------------------------------------");
}
function debug_form_submit(form, form_state) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(form,"form");
console.log(form,"form_State");
console
.log("-------------------------------------------------------------");
}
function debug_node_page_view_alter_article(node, options) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(node,'node');
console.log(options,'options');
console
.log("-------------------------------------------------------------");
}
function debug_entity_view_alter(entity_type, entity_id, mode, build) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(entity_type,'entity_type');
console.log(entity_id,'entity_id');
console.log(mode,'mode');
console.log(build,'build');
console
.log("-------------------------------------------------------------");
}
function debug_block_info() {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console
.log("-------------------------------------------------------------");
}
function debug_block_view(delta,region) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(delta,'delta');
console.log(delta,'region');
console
.log("-------------------------------------------------------------");
}
function debug_page_build(page){
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(page,'page');
console
.log("-------------------------------------------------------------");
}
function debug_services_postprocess(options, result){
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(options,'options');
console.log(result,'result');
console
.log("-------------------------------------------------------------");
}
// Alter the result data of a service call, after its success function.
function debug_services_request_postprocess_alter(options, result) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(options,'options');
console.log(result,'result');
console
.log("-------------------------------------------------------------");
}
function debug_services_request_pre_postprocess_alter(options, result) {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log(options,'options');
console.log(result,'result');
console
.log("-------------------------------------------------------------");
}
function debug_deviceready() {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log("No device, retruning true to continue Drupalgap !"
+ drupalgap.online);
console
.log("-------------------------------------------------------------");
return true;
}
function debug_device_offline() {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log("Device offline, retruning true to continue Drupalgap !"
+ drupalgap.online);
console
.log("-------------------------------------------------------------");
return true;
}
function debug_device_connection() {
console.log(arguments.callee.toString().match(/function\s+([^\s\(]+)/),'debug.js');
console.log("No connection, retruning true to continue Drupalgap !"
+ drupalgap.online);
console
.log("-------------------------------------------------------------");
return true;
}