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

rubicon or delaware
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Rubicon or Delaware

Building Software Which Crosses Rivers

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

slide-2
SLIDE 2

Good Morning

slide-3
SLIDE 3

Agenda

  • Background & example
  • Notable APIs and Services
  • Extension development - demo
  • Core development - demo
slide-4
SLIDE 4

Background: Geopolitics

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

slide-5
SLIDE 5

Background: Geopolitics

joomla.org

wordpress.com

drupal.org

slide-6
SLIDE 6

Example: Add tags to the <HEAD>

joomla.org

wordpress.com

drupal.org

"JFactory::getDocument()

  • >addCustomTag"

"add_action( 'wp_head', 'my_callback'');" "drupal_add_html_head"

slide-7
SLIDE 7

Background: Nomads and the Plains

  • Uncredited. Kyrgyz Nomads via wikipedia.org
slide-8
SLIDE 8

Example: Add to <HEAD> (Polyglot)

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

slide-9
SLIDE 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); } }

slide-10
SLIDE 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; } }

slide-11
SLIDE 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.

slide-12
SLIDE 12

Example: Add to <HEAD> (Breaking the Rules)

Drupal Joomla WordPress

What Civi Does

drupal_add_html_head( "<script src=..." ) JFactory::getDocument()

  • >addCustomTag(

"<script src=..." ) add_action( 'wp_head', 'my_callback'); function my_callback() { return "<script src=..."; }

What CMS Says You Should Do

drupal_add_js(...) JFactory::getDocument()

  • >addScript(...)

add_action( 'wp_enqueue_scripts', 'my_callback''); function my_callback() { wp_register_script(...); wp_enqueue_script(...); }

Benefits of Doing It the CMS Way

Aggregate JS/CSS files Compress CSS files Cache Compiled JS/CSS files Internationalization Weights Aggregate JS (inline) (Plugin) Minimize JS (Plugin) Minimize JS files (Plugin) Aggregate JS/CSS files [No caching] Dependencies Unregistration

Source: Coleman Watts, Donald Lobo

slide-13
SLIDE 13

Background: George and the Delaware

Leutze, Emanuel. Washington Crossing the Delaware (1851). Via wikipedia.org

slide-14
SLIDE 14

Example: Add to <HEAD> (Freedom, etal)

$system->addHTMLHead( "<script type='text/javascript'>...</script>"); CRM_Core_Resources::singleton()

  • >addScriptFile('civicrm', 'js/my-script.js')
  • >addStyleFile('civicrm', 'css/my-style.css')

;

  • Any CMS
  • Any page of any CMS

(Frontend, Backend; Civi- based or CMS-based)

  • Any package type
  • Same ordering
  • Localization
slide-15
SLIDE 15

Next: Key APIs

slide-16
SLIDE 16

Notable APIs

Bridges

  • Initialize, Invoke,

Bootstrap

  • URLs
  • Resources, Titles
  • Users,

Permissions

  • Hooks
  • (et al)

Shared Code

  • Pages, Forms,

Templates

  • API v3
  • DAOs, BAOs
  • DB Upgrades
  • Profiles
  • Scheduler/Cron
  • (et al)
slide-17
SLIDE 17

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}

Notable APIs: CRM_Core_Resources

slide-18
SLIDE 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, ));

slide-19
SLIDE 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', ), ); }

slide-20
SLIDE 20

Next: Extension development

slide-21
SLIDE 21

Extension: In-App UI

slide-22
SLIDE 22

Extension: Directory

slide-23
SLIDE 23

Extension: Evolution

Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules

slide-24
SLIDE 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

slide-25
SLIDE 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

slide-26
SLIDE 26

Extension: The Big Matrix

slide-27
SLIDE 27

Extension: The Medium Matrix

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

slide-28
SLIDE 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

slide-29
SLIDE 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

slide-30
SLIDE 30

Next: Core development

slide-31
SLIDE 31

Core development Github Jenkins

slide-32
SLIDE 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

slide-33
SLIDE 33

Core development: Remove old REST code

slide-34
SLIDE 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

slide-35
SLIDE 35

eof

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