rubicon or delaware
play

Rubicon or Delaware Building Software Which Crosses Rivers Tim - PowerPoint PPT Presentation

Rubicon or Delaware Building Software Which Crosses Rivers Tim Otten Email: totten@civicrm.org IRC: totten Good Morning Agenda Background & example Notable APIs and Services Extension development - demo Core


  1. Rubicon or Delaware Building Software Which Crosses Rivers Tim Otten Email: totten@civicrm.org IRC: totten

  2. Good Morning

  3. Agenda ● Background & example ● Notable APIs and Services ● Extension development - demo ● Core development - demo

  4. Background: Geopolitics Munroe, Randall. Online Communities 2 . (http://xkcd.com/802/)

  5. Background: Geopolitics joomla.org wordpress.com drupal.org

  6. Example: Add tags to the <HEAD> joomla.org "JFactory::getDocument() ->addCustomTag" wordpress.com "add_action( 'wp_head', 'my_callback'');" drupal.org "drupal_add_html_head"

  7. Background: Nomads and the Plains Uncredited. Kyrgyz Nomads via wikipedia.org

  8. Example: Add to <HEAD> (Polyglot) CiviCRM'ish : $system-> addHTMLHead ("<script type='text/javascript' src='/civicrm/goodstuff.js'></script>");

  9. Example: Add to <HEAD> (Polyglot) CiviCRM'ish : $system-> addHTMLHead ("<script type='text/javascript' src='/civicrm/goodstuff.js'></script>"); CiviCRM'ish (How it works) : class CRM_Utils_System { abstract function addHTMLHead ($head); } class CRM_Utils_System_Joomla extends ... { function addHTMLHead ($head) { $document = JFactory::getDocument(); $document->addCustomTag($string); } }

  10. Example: Add to <HEAD> (Polyglot) class CRM_Utils_System_WordPress ... { protected $htmlHeadBuffer = ''; function addHTMLHead ($head) { $this->registered = FALSE; if (!$this->registered) { add_action ('wp_head', array($this, '_showHTMLHead' )); // front-end views add_action ('admin_head', array($this, '_showHTMLHead' )); // back-end views } $this->htmlHeadBuffer .= $head; } function _showHTMLHead () { return $this->htmlHeadBuffer; } }

  11. Background: Julius and the Rubicon Ridpath, John Clark Cyclopedia of Universal History (Cincinnati, OH: The Jones Brothers Publishing CO., 1885). Via etc.usf.edu.

  12. Example: Add to <HEAD> (Breaking the Rules) Drupal Joomla WordPress What Civi Does drupal_add_html_head( JFactory::getDocument() add_action( "<script src=..." ->addCustomTag( 'wp_head', ) "<script src=..." 'my_callback'); ) function my_callback() { return "<script src=..."; } What CMS Says You drupal_add_js(...) JFactory::getDocument() add_action( ->addScript(...) 'wp_enqueue_scripts', Should Do 'my_callback''); function my_callback() { wp_register_script(...); wp_enqueue_script(...); } Benefits of Doing It the Aggregate JS/CSS files Aggregate JS (inline) (Plugin) Minimize JS files Compress CSS files (Plugin) Minimize JS (Plugin) Aggregate JS/CSS CMS Way Cache Compiled JS/CSS files [No caching] files Dependencies Internationalization Unregistration Weights Source: Coleman Watts, Donald Lobo

  13. Background: George and the Delaware Leutze, Emanuel. Washington Crossing the Delaware (1851). Via wikipedia.org

  14. Example: Add to <HEAD> (Freedom, etal) Any CMS ● $system-> addHTMLHead ( "<script type='text/javascript'>...</script>"); Any page of any CMS ● CRM_Core_Resources :: singleton () (Frontend, Backend; Civi- -> addScriptFile ('civicrm', 'js/my-script.js') based or CMS-based) -> addStyleFile ('civicrm', 'css/my-style.css') ; Any package type ● Same ordering ● Localization ●

  15. Next: Key APIs

  16. Notable APIs Bridges Shared Code ● Initialize, Invoke, ● Pages, Forms, Bootstrap Templates ● URLs ● API v3 ● Resources, Titles ● DAOs, BAOs ● Users, ● DB Upgrades Permissions ● Profiles ● Hooks ● Scheduler/Cron ● (et al) ● (et al)

  17. Notable APIs: CRM_Core_Resources Add Javascript CRM_Core_Resources::singleton()->addScriptFile(' com.example.foo ', 'bar.js'); CRM_Core_Resources::singleton()->addScript('alert("Hello")'); {crmScript ext= com.example.foo file=bar.js} Add stylesheets CRM_Core_Resources::singleton()->addStyleFile(' com.example.foo ', 'bar.css'); CRM_Core_Resources::singleton()->addStyle(' body { background: black; } '); {crmStyle ext= com.example.foo file=bar.css} Add images, sounds, etc CRM_Core_Resources::singleton()->getUrl(' com.example.foo ', 'bar.png'); {crmResURL ext= com.example.foo file=bar.png}

  18. Notable APIs: CRM_Core_Region CRM_Core_Region::instance('page-header')->add(array( 'markup' => '<p class="example">Hello!</p>', )); CRM_Core_Region::instance('page-header')->add(array( 'markup' => '<p class="example">Hello!</p>', 'weight' => -5, )); CRM_Core_Region::instance('page-header')->add(array( 'template' => 'CRM/Myextension/mytemplatefile.tpl', )); CRM_Core_Region::instance('page-header')->update('default', array( 'disabled' => TRUE, ));

  19. Notable APIs: hook_civicrm_managed /** * Declare a report which should be activated whenever this module is enabled */ function modulename_civicrm_managed(&$entities) { $entities[] = array( 'module' => 'com.example.modulename', 'name' => 'myreport', 'entity' => 'ReportTemplate', 'params' => array( 'version' => 3, 'label' => 'Example Report', 'description' => 'Longish description of the example report', 'class_name' => 'CRM_Modulename_Report_Form_Sybunt', 'report_url' => 'mymodule/mysbunt', 'component' => 'CiviContribute', ), ); }

  20. Next: Extension development

  21. Extension: In-App UI

  22. Extension: Directory

  23. Extension: Evolution Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules

  24. Extension: Evolution Version Themes 1.x API v1/v2 Custom Template Dir, Custom PHP Dir Drupal Modules 2.x Custom Searches, Custom Reports 3.x CiviCRM Payment , Report , and Search Extensions API v3 Joomla Plugins

  25. Extension: Evolution Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules 2.x Custom Searches / Custom Reports 3.x CiviCRM Payment , Report , and Search Extensions API v3 Joomla Plugins 4.x CiviCRM Module Extension Civix Extension Directory

  26. Extension: The Big Matrix

  27. Extension: The Medium Matrix Platform Package Type CiviCRM APIs CMS APIs Civix Distribution CiviCRM Extension APIv3, Hooks, None Yes civicrm.org (Any CMS) (Module) BaseClasses, (browse) Templates Drupal Module APIv3, Hooks, CRUD, Hooks, No drupal.org BaseClasses*, etc (upload / url) Templates* Joomla Extension APIv3, Hooks, CRUD, Events, No joomla.org (Plugin) BaseClasses*, etc (upload / url) Templates* WordPress Plugin APIv3 CRUD, No wordpress.org [More IP?] Actions, Filters, (browse) etc

  28. Extension: Quickstart ● Configure paths ○ Administer => System Settings => Directories ○ Administer => System Settings => Resource URLs ● Install civix ● Generate a page ○ civix generate:module -h ○ civix generate:page -h See Also: Tutorial on creating & publishing extensions http://wiki.civicrm.org/confluence/display/CRMDOC43/Create+an+Extension http://bit.ly/10gOmNv

  29. Extension: Log IP for Every Change ● Description : Record and display the IP address submitting every database change ● Init module ● Record log data ○ Create SQL table ○ Insert into SQL table during hook_civicrm_post ● Display log data ○ Create page ○ Add page as tab

  30. Next: Core development

  31. Core development Github Jenkins

  32. Core development: Quickstart ● Setup repos ○ Install CiviCRM from tarball ○ Gitify ○ Fork ● Create branch / pull-request ○ Make branch ○ Code ○ Submit pull request Tutorial on using Github & CiviCRM http://wiki.civicrm.org/confluence/display/CRMDOC43/GitHub+for+CiviCRM http://bit.ly/12M8yfr

  33. Core development: Remove old REST code

  34. Further Reading Tutorial on creating & publishing extensions http://wiki.civicrm.org/confluence/display/CRMDOC43/Create+an+Extension http://bit.ly/10gOmNv Reference on APIs, hooks, etc http://wiki.civicrm.org/confluence/display/CRMDOC43/Developer+Reference (Alt) http://bit.ly/13yXiBZ CiviCRM developer tools https://github.com/totten/civix https://github.com/eileenmcnaughton/civicrm_developer Tutorial on using Github & CiviCRM http://wiki.civicrm.org/confluence/display/CRMDOC43/GitHub+for+CiviCRM http://bit.ly/12M8yfr

  35. eof Tim Otten Email: totten@civicrm.org IRC: totten

Recommend


More recommend