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 development - demo
Background: Geopolitics Munroe, Randall. Online Communities 2 . (http://xkcd.com/802/)
Background: Geopolitics joomla.org wordpress.com drupal.org
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"
Background: Nomads and the Plains Uncredited. Kyrgyz Nomads via wikipedia.org
Example: Add to <HEAD> (Polyglot) CiviCRM'ish : $system-> addHTMLHead ("<script type='text/javascript' src='/civicrm/goodstuff.js'></script>");
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); } }
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; } }
Background: Julius and the Rubicon Ridpath, John Clark Cyclopedia of Universal History (Cincinnati, OH: The Jones Brothers Publishing CO., 1885). Via etc.usf.edu.
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
Background: George and the Delaware Leutze, Emanuel. Washington Crossing the Delaware (1851). Via wikipedia.org
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 ●
Next: Key APIs
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)
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}
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, ));
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', ), ); }
Next: Extension development
Extension: In-App UI
Extension: Directory
Extension: Evolution Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules
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
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
Extension: The Big Matrix
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
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
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
Next: Core development
Core development Github Jenkins
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
Core development: Remove old REST code
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
eof Tim Otten Email: totten@civicrm.org IRC: totten
Recommend
More recommend